1

I am trying to resolve this error in Power Automate:

Actions in this flow may result in an infinite trigger loop.
Please ensure you add appropriate conditional checks to prevent this flow from triggering itself.

This seems to be a common problem when using this trigger:

When an item is created or modified

where the associated flow contains this action:

Update item

The dynamic is succinctly explained in these videos here and here.

Desired Behaviour

The desired behaviour is that the flow:

  • Runs when a list item is created or modified by a user (and updates the item accordingly)

  • But not when the flow itself updates the item

Actual Behaviour

The actual behaviour is that the flow:

  • Runs when a list item is created or modified by a user (and updates the item accordingly)

  • Also runs when the flow itself updates the item (causing an infinite loop)

What I've Tried

Some posts suggest using a Service Account to run the flow and then apply the logic:

  • If the flow was triggered by a Service Account, terminate the flow

But I do not have access to a service account in this scenario.  

The simplest solution seems to be answers like this one and this one.

They suggest creating a column in the SharePoint List to store a 'flag'.  

I understand the concept of using flags to indicate:

  • DO run the flow if SOME_FLAG is false
  • DO NOT run the flow if SOME_FLAG is true

But I am having trouble when it comes to implementing them properly in this scenario. 

Specifically, I have added a Yes/No column to my List called LastModifedByFlow.  

The default value is No (i.e. false).

My flow is structured like this:

01)  TRIGGER:  When an item is created or modified

02)  I have added this Trigger Condition

@equals(triggerBody()?['LastModifiedByFlow'],false)

03)  This means the flow will run when LastModifiedByFlow is false

04)  Create some variables  

05)  ACTION: Update the item - this includes setting the LastModifedByFlow value to true

Question

The first time the flow runs, it works great:

  • the item is updated
  • the item's LastModifedByFlow value is set to true so the flow doesn't run again

But how and where in the flow do I set the LastModifedByFlow value back to false?

So that the flow will run each time a user subsequently modifies the list item?
  

user1063287
  • 10,265
  • 25
  • 122
  • 218

2 Answers2

0

It is recommended that you set a default value of “Yes” for the Yes/No column first. When the item is created, the flow will be triggered. After the flow is completed, the value of the column "Yes" will become "No". When the item is modified, it is recommended to manually change "No" to "Yes" to trigger the flow. Here is a post for your reference.

  • I’m checking how the things are going on about this issue. Whether the answer helps you? If there is any problem with this issue, feel free to let me know. – Amy Jiang_MSFT Jul 13 '22 at 02:04
0

I had this issue recently and found this alternative solution. It basically captures if the update that triggered the flow was made by an user or by Power Automate, adding a conditional to terminate if the triggered update was made by the flow: http://digitalmill.net/2023/06/27/bypassing-the-sharepoint-lists-infinite-loop-in-power-automate/

rznt
  • 1
  • 1