Power Automate is well integrated with SharePoint. I believe that it can now be considered a reasonable “successor” to SharePoint Designer workflows. That said, there are some areas where it could be improved. Specifically, if a Flow runs when a SharePoint list item is updated and the Flow also updates the same item, you have an infinite loop. The actions of one instance of the Flow spawn another, and so on. The good news is that there is a simple way to work around or resolve this issue.
My solution leverages a hidden SharePoint Multi-line text column with append text set to on. This column is always empty when you create or edit an item, but you can always view entries made in previous edits. The key is that the column is empty on every edit unless you explicitly populate the column. I am leveraging this feature as a type of “flag”. Every time I use the Update item action in my Flow, I enter text in the multi-line text column. The only time there will be data in that column is if it is put there by Flow. When a user edits the list, the column is hidden, and they cannot enter data. I add a trigger condition that evaluates to true when the column is empty. So, the Flow will never run when the last edit was done via a Flow because the column will never be empty.
Here are some brief instructions on how to test my solution:
- Create a Custom list
- Turn on versioning in the list
- Add a multi-line text column to the list
- Set the column to plain text
- Set “append text” to on
- Hide the column
- Create a Flow that uses the SharePoint “When a list item is created or modified” trigger and a SharePoint “Update Item” action
- Add an expression in the trigger condition that evaluates to true if the multi-line text column is null
- Example: @equals(triggerBody()?[‘MyColumn’],null)
- Configure the Update item action to update item that fired the trigger
- Include some text in the multi-line text column
- Test your Flow by creating and editing a list item
- The trigger should fire once when the item is created and once for each edit of the item
- Add an expression in the trigger condition that evaluates to true if the multi-line text column is null
If you need step by step instructions, read on….
How to turn versioning on:
- Create a Custom list
- Go to list settings
- Click on Versioning settings
- Set “Create a version each time you edit an item in this list?” to Yes
- Set “Create a version each time you edit an item in this list?” to Yes
- Click on OK
How to add and hide an “append text” column
- Go to list settings
- Click on “Create column”
- Name the column “StopRun”
- Select “Multiple lines of text”
- Select “Plain text”
- Set “Append Changes to Existing Text” to Yes
How to make the column hidden
- Go to List settings
- Click on “Advanced settings”
- Set “Allow management of content types” to Yes
- Click on “OK”
- Scroll down the page and click on Item under Content Types
- Click on the StopRun column title
- Select “Hidden” and then click on “OK”
- Go back to Advanced settings and set “Allow management of content types” to No
How to create the Trigger condition
- Create a Flow using the SharePoint When an item is created or modified trigger
- Click on the ellipses in the top right corner of the trigger and then click on settings
- Click on “Add” at the bottom under Trigger Conditions
- Paste the following into the Trigger Condition text box and click on “Done”:
- @equals(triggerBody()?[‘StopRun’],null)
- NOTE: THE QUOTES AROUND StopRun NEED TO BE SINGLE QUOTES . THEY MAY NOT COPY AS SUCH WHEN YOU PASTE INTO YOUR FLOW. YOU MAY NEED TO DELETE AND REPLACE THE QUOTES. ALTERNATIVELY, ENTER THE EXPRESSION MANUALLY.
- The expression checks to see if the StopRun column is null
- If you named your column anything other than StopRun, you can replace StopRun with the internal name of your column
- @equals(triggerBody()?[‘StopRun’],null)
- Add a SharePoint Update item action
- Select your site and list and configure the action per the screen shot below
- Select your site and list and configure the action per the screen shot below
- Click on the ellipses in the top right corner of the trigger and then click on settings
How to test your Flow
- Create a new list item
- Your Flow should run once
- Edit the list item
- Your Flow should run once