A well-known problem with Power Automate is the infinite loop when using the SharePoint “when created or modified” trigger.

The error occurs when a user who created an item starts the flow that will modify that same item and in this way the modification will enter in an infinite loop.

How to solve it

The solution requires you to create an environment variable to use in your trigger settings.

Using Power Automate's best practices, the first step is to create an environment variable containing the service user.

Using Power Automate’s best practices, the first step is to create an environment variable containing the service user.

Power Automate

Then create a variable with the system account email.

Power Automate New Variable

Now, in the trigger settings, use the following instruction.

@not(equals(triggerOutputs()?['body/Editor/Email'], parameters('itRobot (new_itRobot)')))
Power Automate Definitions
Power Automate Definitions

If you are not using environment variables, just pass the email as a string instead of the environment variable.

@not(equals(triggerOutputs()?['body/Editor/Email'], parameters('itRobot (new_itRobot)')))

TIP:

parameters(‘itRobot (new_itRobot)’) and triggerOutputs()?[‘body/Editor/Email’] are values that can be obtained by defining a dynamic variable from the item editor. Then just copy this variable and paste it in any text editor or in your browser’s URL and this value will be displayed in text. The same applies for System Account using a compose for example. And this is how you avoid infinite loop in Power Automate!

Need help with Power Automate, contact us or read more here.