Exception handling in Power Automate Flows

Out of other errors type one is logical errors. There are many reasons for this type of errors, for example, unexpected user input etc.

In most of computer languages we handle these error by exception handling or try-catch blocks. However, in Power Automate we also have this feature available to handle exceptions well in the flow and keep the flow running to complete rest of the flow logic.

There are two ways to implement exception handling in Power Automate Flows. 

  1. Use Power Automate template (https://emea.flow.microsoft.com/en-us/galleries/public/templates/e8e028c6df7b4eb786abdf510e4f1da3/try-catch-and-finally-template/)
  2. Using 'Scope' action with 'Configure Run After'  property

Let's dig into each block in the template

Try - Contain all the actions coming from main flow

Catch - This control configured to run once "Try" block is failed

Finally - This block must run, no matter what is the output of previous block

Now lets configure Try-Catch blocks within a flow.

  • Create an instant flow
  • Add a 'scope' actions



  • Rename the 'Scope' action to 'Try' and add another 'Scope' actions for 'Catch' (and if needed for 'Finally' as well.)
                         

  • Now configure execution of 'Catch'. Click on three dots (...) and click 'Configure run after'. (Perform same steps to configure execution for 'Finally' block)

choose options based on which you want to trigger catch block; You have below four options available.
is successful > if Try block was successful and you want to execute Catch block
has failed > if Try block was failed and you want to execute Catch block
is skipped > if Try block was skipped due to any reason and you want to execute Catch block
has timed out > if Try block was timed out and you want to execute catch block
  • Click 'Done'
  • Now test the flow execution. If there is exception in 'Try' block the 'Catch' and 'Finally' blocks will execute as below


Enjoy

Comments

Popular posts from this blog

How to hide '+' on a subgrid in dynamics CRM?

Get Rid off Pending Email Warning - Microsoft Dynamics CRM

How to Rename Status field options of an Entity in Dynamics CRM