Error handling in Power Automate

18 januari 2021

We all want to build fault-proof flows and we try our best to do so. But errors are prone to happen eventually and when they do, we need to make sure those errors are addressed to the support department so that they can be solved. But how does this work? 


Errors in Power Automate can happen for all sorts of reasons. For example, when you use a wrong data type (integer instead of string) or when your expression is invalid. Fact is that your flow will stop running when an error is encountered and you don't have any error handling configured. Meaning that your flow will not be completed and yout end-user will be waiting on its output for nothing.


Let's say I have a simple flow that will calculate the Christmas gifts budget of the year per person. I have an overall budget of €2500,- that needs to be divided over a number of people, which is dynamic each year. 

This is configured as follows: 


The flow will ask for the number of people and will then divide the total budget (intTotalBudget variable) by the number of people (which is the number_1 output from my trigger). The outcome will be stored inside the numBudgetPerPerson variable and will be sent to the person who is responsible for the Christmas gifts. 

When I run this flow and set the number of people to 9, I will get an e-mail stating the budget per person: 


But after making some changes to the flow, I've accidentally set the People input of my manual trigger to optional instead of required. When I run this flow now and forget to put in the number of people, the flow will error: 


Please note the status of the E-mail action. It has a grey cross, meaning that the action has not been run. That's because the previous action which did the calculation of the budget per person has failed You can see the error message in the red box of the action itself and also in the details pane on the right side. 

In some cases, the error is matched to a known issue and the details pane will give you a possible solution to the error. In this case, the error isn't known so that's why you're getting the Ask the Power Automate community option. 

Error handling.

In the previous example we saw that when a flow errors, the following actions will not run by default. In this case, the person responsible for the Christmas gifts will not receive the budget per person and may be getting the Christmas gifts too late. This is something that someone should be notified about. 

Power Automate does send out failure alerts (see below for an old example) to the flow owner(s), but this is on a periodic schedule. You rather want to be informed immediately when a flow errors so you can take action right away. 


Run after conditions.

The way to deal with error handling is by using so called Run after conditions. This will allow you to configure when an action should run. You can do this by configuring the next action (in this case sending an e-mail to support that the flow has failed) and clicking its ellipsis (top right corner) followed by Configure run after


This will switch to run after mode: 


By default each action will run after the previous action(s) has been completed succesfully. But you can also configure to run when the previous action(s) has been failed, skipped or timed out. 

In this case, we can only want this e-mail to be sent when the previous action has failed. So we make sure only the has failed option has been selected. 


When clicking done, you will see that the default solid arrow has now changed to a dotted red arrow and that the information symbol has appeared. This will notifiy you that the Run after condition has been configured. The other e-mail action still uses the default setting; it will run after the previous action is succesfull: 


When the flow is triggered again without the number of people filled in, the support department will now receive an e-mail stating that the flow has failed and needs to be looked at: 


Completion status.

You'll see that the flow still is an errored state, which will result in the periodic failure alert still being sent. This isn't really necessary anymore, because support has already been notified about the issue. If you don't want the flow to enter an errored state, you may want to add a Terminate action after your error notification with a Succeeded status: 


When we resubmit the flow, you'll see that the flow is now in a successful state: 


Advanced error handling.

In this blogpost, I've explained to you how to configure basic error handling. There is also a way to configure a more advanced way of error handling in which the e-mail will contain more information about your flow and about the error itself (which action has failed and why did it fail), which will make it easier to troubleshoot. 

I will cover this in a blogpost that will be posted next month so please follow us on social media to stay tuned and to be kept updated on other Power Platform related stuff as well! 

Source: https://www.about365.nl/2020/11/24/error-handling-in-power-automate/


Submit a comment