When it comes to building flows in Power Automate, a best practice tip is to set up the flow to handle errors. This is especially important for business critical flows- you wouldn’t want to flow run to just fail, you would likely want an alternative set of actions to occur in case your flow run didn’t go as planned.
You can use the Try, Catch, and Finally method to configure how errors are handled in your flows. It allows you to make your flows more reliable, so you can identify (“catch”) any errors that occur and have a back-up plan in place.
- Try: In this scope, you create the main steps of your flow.
- Catch: In this scope, you create the steps that should occur upon failure of your main steps
- Finally: In this scope, you create the steps that should occur when the flow completes, either upon success for failure. This may not be necessary for you flow if all the actions are already contained in the Try or Catch stages.
As an example, I will use the Try, Catch and Finally template that exists in Power Automate. This template already has the scopes and a failure action set up. However, it is easy to build this from scratch too.
To add a scope in your flow, you just need to add in a new step and look for scope. This is like a virtual container. Within the Try scope, you can create your flow as normal, with the steps that should occur. Note, in the example below, the steps I have added are not part of the template.
The next scope in your flow should contain the actions that should occur if anything during the Catch stage was to fail. You need to Configure run after for the Catch scope as shown below.
Here, you can specify when the Catch steps should run. As you only want it to run if anything as part of your main flow fails, you can set it so that it runs if the actions in the previous scope fail, are skipped or have timed out.
If you have any other actions, they can go in the Finally scope. Otherwise, your flow is done and can withstand errors!