Power Automate Standards: Error-Handling
Power Automate Standards: Error-Handling Table of Contents Try, Catch, Finally Pattern Group Multiple Actions Inside Of A Scope Action Terminate The Flow Wit...
- Published
- Reading time
- 3 min read
Before you start
Is this guide for you?
- Best entry point
- Power Automate
- Time investment
- 3 min read
Imported reference from Matthew Devaney's blog for learning purposes. Original: https://www.matthewdevaney.com/power-automate-coding-standards-for-cloud-flows/power-automate-standards-error-handling/. Author: Matthew Devaney.
Power Automate Standards: Error-Handling 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.
actions( 'Compose:_Test_Value' )?[ 'error' ]?[ 'message' ] Code language: JavaScript ( javascript )
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.
outputs( 'Compose:_Get_Workflow_Details' )?[ 'tags' ]?[ 'environmentName' ] Code language: JavaScript ( javascript )
Flow expression #2 extracts the flow’s unique identifier.
outputs( 'Compose:_Get_Workflow_Details' )?[ 'name' ] Code language: JavaScript ( javascript )
Flow expression #3 finds the flow run’s unique identifier.
outputs( 'Compose:_Get_Workflow_Details' )?[ 'run' ]?[ 'name' ] Code language: JavaScript ( javascript )
The failure notification email looks like this: Did You Enjoy This Article? 😺
Subscribe to get new Copilot Studio articles sent to your inbox each week for FREE Enter your email address Sign Me Up Questions?
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.
Tagged
Power Automate
Have a Microsoft 365 topic idea?
Share article suggestions, community session ideas, corrections, or real-world scenarios for future nextM365 learning notes.
Keep learning Microsoft 365
Explore more practical guides for SharePoint, Power Platform, Copilot Studio, migration, automation, governance, and security.
Continue learning
Related tutorials
Related questions
Related comparisons
Next action