I have a SharePoint list on which a flow operates. The flow is triggered by new or edited items.
Problem: The flow itself updates the item from which it was triggered. This, of course, triggers the flow again. If I took no measures, the flow would trigger itself again and again.
I took the following measures to prevent permanent self-triggering:
- Just before performing the modification of an item in the list, the flow will check if the fields inside the item which were meant to be changed already hold the changed values.
- If so, the change is skipped and the trigger is not issued.
This has two drawbacks:
- The flow is at least triggered twice per item. The first time when a user is doing an edit; the second time after the flow itself made its updates
- To check the necessity of doing the edits within the flow, all calculations and data work has to be done as if it were for real. And as I'm parsing other lists to do the calculations, it means some data and processing load which is essentially unnecessary.
I currently don't know how to circumvent that behaviour. And I'm planning to implement another flow which frequently does edit a lot of items which would trigger the first flow many times. I'm in need to find a solution to this.
I thought of different possibilities but lack knowledge about feasibility. Every solution I think of brings up another problem:
- I could add a column in which I code the ID of the flow which has edited the item last. Let's say 1 for the triggered flow, 2 for the regular flow. The triggered flow should bail out on 1 and 2, i.e. should only operate on user actions. But I know of no means to reset the ID to let's say 0 after a user edit. Pre-filled columns only work on new items not on edits. Calculated columns can't be written by flows, etc.
- Could add a timestamp which is set only by a flow. The next execution of the flow could check if the date of the flow matches the last edit date. But this would be rather imprecise, the times will still differ and I can't rule out accidental near-simultaneous edits from user and flows.
- I think of other properties in the edited item which could identify the source of the edit, but I don't know of any. The flow runs with my user ID, so every edit seems to be done by me. Currently I don't have access to other accounts.
Any ideas how to make idea #s 1 to 3 work, or even a #4?
Addendum: I thought I had one solution:
I add a column, let's call it EditByBot to my list, most likely an integer number. I don't hide that field, so it will appear in add and edit form.
I let the default value of that column be 0.
I add a rule to the column checks of that list (I don't know the proper name for that setting within list settings, over here it has the name Überprüfungseinstellungen). The rule says, the column EditByBot has to be 0. The Rule can be formulated as
=([EditByBot]=0)
Any flow operating on a list item will set that column to a number other than 0 identifying the flow.
Unfortunately the edits of my flow are subject to the same rule checks as an edit in a form.