Introduction
In power automate there will be times where Power Automate Flows fail. These are sometimes frustrating especially if you don’t know it has failed. So how do we handle Flow failures? There are a few ways we can do this, in this post we will cover how to handle these and some suggestions to make it easy to identify these errors
Run After
The most popular way to handle Power Automate Flow failures is to use the ‘Run After’ setting, this allows you decide what should happen after each action. The ‘Configure run after’ setting has 4 options:
- is Successful
- has failed
- is skipped
- has timed out
By default the ‘is successful’ is checked on all actions so the next action will only continue if the previous action has successfully run.
To use the ‘Configure Run After’ setting on an action, click the 3 dots and select ‘Configure Run After’
If we check ‘has failed’ if the previous action has run the flow will continue if the previous action fails, however if the flow should also run is the previous action ‘is successful’ then you should also check ‘has failed’ too.
For the below example we have tried format a date/time however the date is not formatted correctly so we expect this to fail. We have added ‘has failed’ so the next action will run only if previous action has failed.
When we run the flow we can see the ‘Compose’ action has failed because we added the ‘has failed’ in the settings for the ‘Compose 2’ action even though ‘Compose’ failed we were still able to run ‘Compose 2’.
You will also notice when you add ‘has failed’ the arrow down to the next action will have a an ‘i’ next to it, this symbols a change from ‘is successful’
As we can see from the image above the flow has failed but on run history we can see that the flow passed. This is because Power Automate will pick up the last action that ran to determine whether the flow run has passed or failed.
Returning Results for Successful and Failed Runs
We have seen how to continue running flow if a flow failed, but how about if we still want the flow to run but if we want to do something different if the flow fails.
Just like before we can still use the run after setting, however this time we can add in 2 compose actions to give us the output. After the ‘Compose 2’ action we can add a another compose action this time if we set this to ‘is skipped’.
This will run the flow if the previous action didn’t run and was instead skipped. Therefore if ‘Compose’ action failed, ‘Compose 2’ will skip because the ‘Compose’ was successful and then because we set ‘is skipped’ on ‘Compose 3’ we will see the output for ‘Compose 3’.
We can now see below that ‘Compose’ action was successful so ‘Compose 2’ skipped so then ‘Compose 3’ was successful.
If we then wanted to do different things based on the ‘is successful’ or ‘is failed’ action we could do this 2 different ways:
- Add a Condition
- Add a Parallel Branch
Condition Method
For the the first option we could introduce condition, since we are skipping a step depending if ‘Compose’ action passed or failed we could look to check for an empty value.
Parallel Branch Method
Another way we can handle errors is by using the ‘Parallel Branch’ this method allows us to still doing something with an error and also makes it visually easier to see. We still need to add ‘has failed’ to the configure run after, however it makes it a lot easier to see visually when running the flow.
Error For Entire Flow
Error handling gives is good control over our actions to be able to handle what happens when the entire flow fails before or after error handling. The problem with handling this at an action level is that this will only run on the particular actions that are specified. Things change, what works today might not work tomorrow, especially as new updates happen over time and data gets changes etc.
So how do we handle error handling for the entire flow?
One method we could use is the ‘Scope’ action. The Scope action is basically a container so a set of actions can go inside a Scope and makes is visually easier to view in the designer. However we can also use the same method for error handling.
As you can see below we have added a Terminate with Status of ‘Failed’ if run after = ‘has failed’ if the ‘had failed’ terminate = skipped then then the flow will terminate with a status of ‘Succeeded’