In this blog we will be going through the steps of Error Handling in Microsoft Flows.
Step 1: We have created a basic flow that is triggered when a HTTP POST Request has be made to the generated URL. The body will contain a JSON array with some data
The flow will then take the data passed in the POST request body and for each object in the JSON array, it create a record in Dynamics 365 Customer Engagement as shown below.
In the above scenario we pass the correct data, but in case the data that is passed to the URL is not correctly formatted or the data is missing we will encounter an error and the flow will fail.
To handle such situations we will define an action that will take place when an error is encountered.
Step 2: To Log the error, we will create another action to create a log error log in Dynamics 365 Customer Engagement. To make sure that this is created only when an error is encountered we click on the Configure Run After option as shown
There are four options shown, here we select only the “has failed” option which states that the log will be created when there is a failure.
Once this is done we can see the the flow shows a dotted red line for the last step, this is because the “Log Error in CRM” action will run only in one scenario i.e. when the above action has failed.
The benefits of using this approach in our flows is that we can log all the errors at one place and also store the error response of the previous stage by simply selecting the Dynamic Content in the “Log Error in CRM” action.