Error handling in Power Automate

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

In this blogpost, I will explain how to do this.

Errors

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 your end-user will be waiting on its output for nothing.

Example

Let’s say I have a simple flow that will calculate the Christmas gifts budget of this 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 email 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 Email 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 way.

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 email 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 successfully. But you can also configure it to run when the previous action(s) has been failed, skipped or timed out.
In this case, we only want this email 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 an information symbol has appeared. This will notify you that a Run after condition has been configured. The other email action still uses the default setting; it will run after the previous action is successful:

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

Completion status

You’ll see that the flow still is in 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 mail 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 email 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 me on social media to stay tuned and to be kept updated on other Power Platform related stuff as well!

 

One Reply to “Error handling in Power Automate”

Leave a Reply

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

This site uses Akismet to reduce spam. Learn how your comment data is processed.