Use try catch in Power Automate

With the Try- catch concept you are going to “try” doing an action and if it fails you are going to “catch” that the flow has failed and notify the right user.

The first step is creating an action in your flow. For example you wont to send mails from another email address.

mail

After that action we are going to initialize a variable.
This variable is going to be a Boolean.
To let it run after the previous action failed you need to go to the “Configure run after” settings of the variable

mail

In the “run after” settings we deselect “is successful” and select all the other options because we want to know when the action above has failed, has been skipped for some reason or has timed out in an approval flow for example.

mail

After this action we are going to check if the “HasRunFailed” variable is false or true and depending the result we are going to continue with our flow or send an email to the responsible person to notify that the flow has failed.
After you notified the right person you need to “terminate” the flow otherwise the flow will get a “success” status because the last action was done successfully.

mail

Make sure that you configure the “run after” of the condition to make sure that it always runs.

mail

If you want to give the person you notified more information you can get the details of the flow by using the “WorkFlow()” function.
With this function you will be able to reconstruct the link to that exact run of your flow to see where the flow has failed.
outputs(‘Compose’)?[‘tags’]?[‘environmentName’]
outputs(‘Compose’)?[‘name’]
outputs(‘Compose’)?[‘run’]?[‘name’]
To add the link the mail you can easily do this with a concat function
concat(‘<a href=’,outputs(‘Compose_2′),’> Click here </a> ‘)

mail

From now on if the mail step fails the user will get a mail that looks likes this.

mail

Plaats een reactie

Maak een blog op WordPress.com.

Omhoog ↑