Summary
Have you seen the following error in your 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.“
If your answer is yes, then please keep reading…
As you can see the warning is telling you “it may” and you need to “add appropriate condition checks”.
So to demonstrate that, I am going to create a scenario to get this warning and address it. I will create a simple custom list (named InfiniteLoop) with a default ‘Title’ field. Then I will create a flow with a trigger “When an item is created or modified”. In this flow, I will use a random number generator function rand to generate a random number from 1 to 75. The flow will append the generated random number to the Title field and call Update item.
After all that, it will show me a warning in the Flow checker as seen below.
# code for the compose is
concat ( ' ' , rand(1,75))
# code for the Update 'Title' is
concat ( triggerOutputs()?['body/Title'], outputs('Compose'))
Step By Step Solution
There are multiple ways to solve this infinite loop issue.
You need to add a trigger condition to your flow so it only fires when condition is met and does not fire back again after update item in your flow.
Solution # 1 : Utilize ‘Modified By’ field as the trigger condition.
Basically, what you want here is to set a trigger condition to check “Modified By” Email is NOT equals to a user’s email(flow author’s email). In my scenario BobK created the flow.
You can simply copy paste the following formula to the Trigger Condition, and change the email address appropriately.
# First modify by check email is null,
# if yes, return true
# if no, convert to lower case and compare to flow author
# Make sure to change the email address after copy and paste
@if(equals(triggerOutputs()?['body/Editor/Email'],null), true, not(equals(toLower(triggerOutputs()?['body/Editor/Email']),'bobk@gov963094.onmicrosoft.com')))
NOTE: Please make a note, if the Flow Author user makes a change to the list item, the flow will not trigger. This is a downside of this technique. If you are a flow author and you will not be end user to update the list items this technique will work great for you.
Solution # 2 : Create a Copy of the field to do compare.
In this technique for above summarized scenario. I will create a new field e.g. “Title_Copy”. This field will hold the copy of the data from the “Title” field. The new Title_Copy field will be hidden from the user. The copy will be made in the flow with update item.
The flow will have a trigger condition to check if the “Title” and “Title_Copy” are NOT equal. If they are not equal that means the user has made the change to the Title field. So allow flow trigger to fire.
If they are equal that means the change is made by the flow at the time of the update. So do not allow trigger to fire.
# To fire the trigger, check if the Title and Title_Copy are NOT equal.
@not(equals(triggerOutputs()?['body/Title'],triggerOutputs()?['body/Title_Copy']))
Solution # 3 : Create a Copy of the field to do compare for more than one fields.
So far ok if you were only interested in the one field user makes the modification. What if you have more than one field which your flow is interested to check whenever a user makes a modification. The above #2 technique may need to be adjusted.
Basically, you will make a master Copy filed with multi text type. This field will be hidden similar to the #2 solution. This field also will be updated in the flow.
But update will be concatenation of the all required fields your flow want to trigger on.
To be continued… (I will complete this later as I get time)
Conclusion
As you can see there are multiple ways you can avoid infinite loop. Please let me know your comments.
Hi, thanks for this great article, Im wandering if you could help me with a related issue.
I created a flow that sends attachments from a SharePoint List register to a Document Library in SharePoint. I want the flow to delete the attachments in the list after they have been sent to the SharePoint Library.
My Flow: When an item is created, Get Attachments, Apply to Each (Get Attachment Content – Create File – Update File Properties). I am trying to add a Delete Attachment to the end of the flow, but I get the warning Actions in this flow may result in an infinite trigger loop. In the Delete Attachment part of the flow I have the When an item is created or modified ID as *Id, and the Get Attachments Id as *File Identifier.
I am very new to Power Automate, this is my first flow.
Thank you very much in advance for the help!
Hey, thanks for this! I may not be interpreting what you’re trying to achieve correctly, but wouldn’t you want the null check to return false if it equals null (i.e. we want the condition to only run if the connection email is not equal to the body/editor/email, AND if the body/editor/email is equal to null)? After changing this from True to False, it worked for me.