DEV Community

Frederik Van Lierde
Frederik Van Lierde

Posted on

Error Handling in Power Automate Loops

When working with automated workflows in Power Automate, we often encounter tasks that need to run repeatedly through loops. A common challenge arises when some of these tasks might fail, for instance, due to external dependencies or unexpected input values. In such cases, allowing the entire flow to fail isn't ideal. Instead, we want to handle these errors gracefully.

Take, for example, a scenario where we're setting permissions for a list of users on SharePoint items. Not all users might be recognized by SharePoint due to various reasons like misspellings or account issues.

If a user isn't found, the action to set permissions fails. However, rather than stopping the whole process, it’s beneficial to capture these errors, continue setting permissions for other users, and send a notification detailing the issues encountered.

This approach ensures that one error doesn't halt the progress of the entire workflow, and we remain informed about which users need our attention. In the upcoming sections, we'll explore how to effectively use Power Automate to manage such errors, ensuring our workflows are both robust and informative.

The Flow

I made a simple flow, as I want to show the basics

The Flow

The Steps

The main part of the solution is to set the scope (or the action) to execute only when their is a failure

  • Go to settings of the Scope (or action)
  • Under Run After, click the arrow
  • Select Has Failed
  • De-Select Is successful

Error Handling

Result

When the previous access failed, execute and continue, when the previous action is successful, do nothing and continue with the loop

Top comments (1)

Collapse
 
bikeknife profile image
Andy

This is great Frederik and something I wish could be handled in a more elegant way.

What I have done is to put an 'add row' in the scope to log some details about the current loop item. I was interested in how tracked properties might be useful for this but got busy with other things and never revisited it.

I look forward to your additional posts on this.