CRM Crate

Understanding & implementing the Try & Catch in the Power Automate

In this course, we will to learn to understand & implement the Try-Catch (Error Handling) in the Power Automate. Before we start, make sure to subscribe to CRM Crate so that you stay up-to-date in the field of Microsoft Dynamics 365 CRM.

Why do we need error handling capabilities in the Power Automate?

As far as application programming is concerned, some operations / logics can fail. We define the working logic in the “Try” block and define the error handling response or logic in the “Catch” block. The same concept applies in the Power Automate flow, we can define the “Try” and “Catch” within the flow so that we can achieve the error handling capabilities of Power Automate.

Step 1 – Create a sample blank Power Automate flow

  • Navigate to the Power Automate studio and create a new blank flow as shown below.
Try Catch Power Automate
  • Trigger the Power Automate flow as per the need. In our case, we have triggered the Power Automate flow on update of an entity record.

Step 2 – Create & define the Try-Catch blocks

  • In the search bar, search for an action called “Scope” as shown below.
  • Rename the newly inserted Scope control as “Try”. Further add one more new Scope control and rename it to “Catch” as shown below.
  • In the Catch control, click on the more option >> Configure Run After as shown below.
  • In the Catch configuration, define the scenario for which the Catch block should get executed . In our case, we have executed the Catch block when the above created Try block has failed or has a time out in its operation. Click on done once the configuration has completed.
  • Now, we have added an operational logic which needs to get executed in the Try block. In our case, we have written a logic to create a new “Subscriber” record on an update of the “Research & Development” record.
  • The field “SRL” is an integer field and accepts the input value in range of 0 to 10. For successful execution, we have added a valid value “1” for the given SRL field of the “Subscriber” entity. *
  • The Try block will only be executed if the given Subscriber record is successfully created in the dataverse.
  • Similarly, we have defined an operational logic in the Catch block. In our case, we have sent an email to the concerned admin in-order to inform the failure.
  • The Catch block will only be executed if there is any failure in the operation defined in the above Try block.
  • Save the flow once the above steps are been completed.
Try Catch Power Automate

Step 3 – Test the Try Catch implementation flow

  • Now let’s trigger and test our flow. In our case, we have triggered the flow by updating an existing record in the “Research & Development” entity.
  • Once the flow has triggered, open to the Power Automate studio, navigate to the above created flow and verify the flow execution history.
  • Here we can see that our flow has successfully executed and the working logic present in the Try block has executed with success. Due to this, only the Try block got executed while the Catch block remained un-executed as shown below.
Try Catch Power Automate
  • Now, let’s make some change in the above created flow in-order to fail the working logic present in the Try block. Now in the Try block, we have defined a logic to create a new “Subscriber” record with faulty default value in field “SRL”. As we had mentioned earlier, the field SRL only accepts the integer values between the range of 0 to 10. So, in-order to fail the Try block, we have now inserted an invalid value “-1” in the SRL field as shown below.
  • Save and re-trigger the flow. Again navigate and open the execution history to verify the execution.
  • Here we can see that the Try block has failed due to an incorrect input parameter and hence the flow has skipped the Try block and the Catch block got executed.

Thus we learned and implemented the concept of Try & Catch using the Scope control in Power Automate.

5 2 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
error: CRM Crate Security Engine - Disabled Right Click & Selection!

Congratulations!

Well Done,
Welcome to CRM Crate

Stay tuned with us and get all latest updates and learning in Microsoft CRM and related techonologes.