Best Practices for Error Handling

Dealing with errored Power Automate flow runs can be a frustrating experience for makers. Especially if a workflow fails on production, this can put added pressure on the team to resolve ASAP. Having to review a workflow that may run thousands of times a day/week means combing through hundreds of past runs. Without any additional context of the data, this can turn into trying to find a needle in a haystack.

Fortunately, there is a pattern we use here at Kumo Partners that streamlines error handling to quickly identify root-cause. This is done by using the various properties on the triggerOutputs() object and combining them with the concat() expression. This is how we can re-create the URL that someone would be clicking from the run history.

Each Power Automate Run has its own dynamic URL that we can re-create.

Code Sample

concat('https://flow.microsoft.com/manage/environments/', triggerOutputs()?['tags']['environmentName'], '/flows/', triggerOutputs()?['name'], '/runs/', triggerOutputs()?['run']['name'])

This expression references the name of the environment, the name of the flow, and the name of the current run in order to create the proper URL.

Example Workflow Use

To use this expression in your Power Automate workflow, simply add it to whatever action you like. I suggest configuring a compose action with this expression as the input. That way it will output this value making it easier to reference in the rest of your workflow.

Creating a Compose action to store the Concat() expression

Looking at the screenshots above, you can rename the compose action to ‘FlowRunURL’, allowing you to reference in HTML:

<h3>View the Flow: <a href='@{outputs('FlowRunURL')}'>Link to Flow Run</a></h3>

This can then be referenced in a Send Email action or stored in a database.

In Summary

By leveraging the power of the concat() expression and the triggerOutputs() object, you can simplify your error handling process and make it easier for users to quickly identify and resolve issues in your workflows.

For other content related to this check out our Youtube channel in order to get even more information regarding Power Platform best practices!


0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *