Exception Handling and Scopes in Power Automate

Loading

Exception handling is a mechanism that allows Power Automate for desktop to handle and recover from unexpected circumstances and issues that might occur during a flow run.

Here i am using a Flow which is about moving an item in SharePoint.

When i run the flow an error has raised as shown below

Here I am also Initializing a variable and adding a send email action to the flow.

When i run the flow some errors have occurred though i have an issue with one step whole flow will not be run.

So, to avoid such type of errors we can use “configure run after” option

Getting notifications when your flow has failed because of an error is critical to maintaining business continuity. Also, the notification should provide the cause of the error to help you resolve it quickly. This module will focus on how you can use Configure run after, an option that is available for flow actions, to help isolate errors. It also overviews the built-in error reports.

When we have only one error in a step the remaining steps will be Executed by using Configure run after

Where we can run the flow based on previous step result like is successful, has failed, is skipped, has timed out. With the Configure run after option, you can identify which step failed and, if it did, bring that to your attention. The setting, is successful, in the notification is the default; however, you would use the has failed setting to handle errors.

Lets run the flow when the previous step has failed

Then the flow ran successfully excluding the error step.

Lets use a parallel branches action in the flow.

Add a parallel branch for immediate notification

Adding a parallel branch allows you to add a mobile or email notification step to inform the maker of the flow in which an issue has occurred.

Add two email actions to the branch in which we can check the configure run after option by selecting two conditions 1.when the previous step is successful 2. when the previous step has failed

Add the mail receiver address and subject and body as shown below

Now test the flow by selecting recently triggered flow as shown below

When we run the flow the result will be shown below where we can see a red dotted arrow mark because it runs when the previous step has failed.

Here i am adding get file properties for my source library.

Run the flow automatically by selecting recently triggered flow

when we run the large flow we may not find where the exact error is coming

To avoid such kind of actions we are using scopes for that. Scopes are used to combine multiple action inside a logical group.

After adding scopes just drag and drop the below steps into the scopes

After adding insert a parallel branch to separate the mails when the Configure run after choices may differ like previous step is successful or has failed

Insert “set variable” action after get file properties as shown below

Now add another scope action to the flow

After adding required steps rename the scopes with try and catch

Set the configure run after to when the previous step has failed to the 2ns scope

Run the flow as shown below

Now we can see which step has run successfully or failed

Though the try scope has failed the catch scope has run successfully

Leave a Reply

Your email address will not be published. Required fields are marked *