powerautomate

Error Handling Demo

Getting notifications when your flow has failed because of an error is critical to maintaining business continuity. Also, the notification should provide the cause of the error to help you resolve it quickly.

In this Lab

This lab will focus on how you can use Configure run after and terminate flow, options that is available for flow actions, to help isolate errors. It also overviews the built-in error reports.

Task 1

a. Let us start with creating a cloud flow that will fail :)

image

b. Adjust the values for the Site Address name and List Name name to your values

c. Save and Test the flow

Note: The SharePoint item ID is not on the list. This will make the flow fail.

c. Check the Cloud flow activity for failed runs. This typically takes some time to reflect, making error handling even more important.

Task 2

Now we will add error handling for the Update Item step in the flow:

a. Add a parallel branch after Update Item action. Choose the Send an email(v2) operation in the parallel branch.

image

b. Configure run after by clicking on the three dots on the Send an email action

image

c. Select Has failed in the run after menu. This will ensure that this parallel branch action runs only if the previous action (Update an item) fails.

image

Note: The parallel branch turns into a dotted red line. This indicates that run after has been configured.

d. Save and Test the flow. Verify the flow run and check your email for the failed run.

image

Note: While the run after operation can be very useful to send instant notifications for failed actions in a flow, it can be difficult to implement error handling on every action. So we need to implement something more generic, which notifies immediately after the flow fails(without knowing which action failed).

Note: All actions in the left branch were skipped as soon as the Update an item action failed.

Task 3

a. Remove the parallel branch by deleting its action. Add a new Send an email(v2) action at the end of the flow.

image

b. Configure run after by clicking on the three dots on the Send an email action

image

d. Save and Test the flow. The flow should run successfully (even though Update an item action failed). This is because our error handling is good.

image

Task 4

a. Update the name of the last action to Failure Email

b. Add a new control step Terminate. This will terminate the flow only if the Failure Email has successfully run.

image

c. Update the email body to include more details from the flow.

concat('https://make.powerautomate.com/environments/', workflow()?['tags']['environmentName'], '/flows/', workflow()?['name'], '/runs/', workflow()?['run']['name'])

image

d. Save and Test the flow. Verify the email recievied with a link to the failed flow run.