Table of Contents • Try, Catch, Finally Pattern • Group Multiple Actions Inside Of A Scope Action • Terminate The Flow With A Status Of Success Or Failure • Notify The Process Owner Of The Flow Failure • Get The Flow Error Message For The Failed Action • Include The Flow Run History URL
Try, Catch, Finally Pattern
Check for errors and tell Power Automate how to handle them at possible failure points in the flow.
The Try, Catch, Finally pattern for error-handling pattern is found in most programming languages:
- Try – Attempt to execute one or more flow actions
- Catch – When an error occurs, do these steps next
- Finally – always run these actions whether the previous actions succeeded or failed
Here’s how to create the Try, Catch, Finally pattern with Power Automate.
Configure the “run after settings” as shown for the flow actions below.
Group Multiple Actions Inside Of A Scope Action
When multiple actions have the same error-handling requirements place them inside a scope action. A scope action holds a set of other actions.
Then configure the run-after requirements for the scope. Now any action inside the scope will trigger the error-handling behavior.
Terminate The Flow With A Status Of Success Or Failure
A flow using error-handling will continue to run after it encounters an error. It will end with a status of succeeded even though there was a failure. To overcome this issue, include terminate actions as the final flow steps to ensure to correct status is displayed in the flow run history.
Notify The Process Owner Of The Flow Failure
Alert the business process owner when the flow fails to let them know there was an issue. If no one is notified when the flow fails then it will not get fixed and could continue to happen.
Get The Flow Error Message For The Failed Action
The reason for flows failures are not often not known in advance. This makes writing an error message before-hand difficult. By using the actions expression we can extract a useful error message from the flow action that failed.
Add a failure reason section to the flow failure notification and use this expression.
When the flow fails an error message will appear in the flow run history.
Then the message gets included in the flow failure notification to the business process owner who will take action on it.
Include The Flow Run History URL
A clickable link to the flow run details should be added to the failure notification. The message can be forwarded to a developer who can quickly identify the failed flow run in the history. Then they can review the issue and diagnose the problem. To do this, use this following coding pattern:
Flow expression #1 gets the environment’s unique identifier.
Flow expression #2 extracts the flow’s unique identifier.
Flow expression #3 finds the flow run’s unique identifier.
The failure notification email looks like this:
Did You Enjoy This Article? 😺
Subscribe to get new Power Apps articles sent to your inbox each week for FREE
If you have any questions or feedback about Power Automate Standards: Error-Handling please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.