Power Automate - Infer the Flow Run URL

Do you automate tasks by creating flows with Power Automate? As an administrator or maker, you may need to look at previous executions of a flow for monitoring or troubleshooting purposes. What if you could infer the flow run URL during the execution of a flow? Wouldn’t that be great? Here’s how in 4 easy steps.

Usually, to view  a flow execution logs, you must go to the management page of a given flow. There you can view the run history section and, for example, identify a failed run (see image below). By clicking on a flow run link, you will reach the execution page of a flow session and will be presented with detailed insight on the execution.

Image montrant comment consulter l'historique d'exécution d'un flux dans la page de gestion du flux concerné

Now, there is a way to infer this link while the flow is running. Indeed, by deducing the run URL in real-time during the flow execution, you can for instance:

  • Email the flow run URL to an administrator if an error occurs.
Envoyer par courriel l’URL de l’exécution à un administrateur en cas d’erreur.
  • Save the Flow Run URL in a Dataverse record for further investigation.
Enregistrer l’URL de l’exécution dans un enregistrement Dataverse pour un examen plus approfondi.

Infer the flow execution URL: 4 easy steps

1. Use the workflow() function

First, you must extract certain data about the context of the flow currently executing. To do so, use the workflow() function that you will find under the Expression tab within the Dynamic Content explorer.

Actually, the workflow() function creates a JSON output as illustrated below. Some of these returned attributes will serve as a base for the flow run URL you want to build.

2. Parse the JSON output

Now that you know how to get information using the workflow() function, let’s continue and parse the JSON output. At this stage, you will be able to extract values mentionned above and use them easily in further steps of your flow.

First, add a Parse JSON action and insert the workflow() function in the content box. As for the schema, do not bother with entering it manually. Simply click ‘’Generate from sample’’ and insert an output example, like the one shown in the previous step. The JSON schema will be automatically generated! It is that simple!

Parse JSON - Workflow
Power Automate - Ajoutez une action Parse JSON et mettez la fonction workflow - générer à partir d'un échantillon
ajoutez une action « Parse JSON» et mettez la fonction workflow() comme contenu.

That way, the extracted attributes can be used in the next steps of the flow, directly from the Dynamic content tab. This will save you a lot of headaches later.

Accès facile aux propriétés extraites - Workflow json outpu

3. Build the URL

You have reached the final step – developing a URL in a similar format as this one:

https://flow.microsoft.com/manage/environments/{environmentid}/flows/{flowid}/runs/{runid}

Pro tip!

Using flow.microsoft.com as the URL root, your URL will be valid independently of the geographical hosting site of your flow.By clicking the generated link, you will be redirected automaticallyto the right domain (i.e. us.flow.microsoft.com, canada.flow.microsoft.com, etc.)

Now, to build the URL let’s add a Compose step and make use of the concat() function and the attributes extracted from the Parse Json step to stitch all the parts together. The final expression will look something like this:

Pour joindre toutes les parties de la composition de l’URL, utilisez la fonction concat(). Ainsi, l’expression finale aura l’air de ceci :

concat(

‘https://flow.microsoft.com/manage/environments/’,

body(‘Parse_JSON’)?[‘tags’]?[‘environmentName’],

‘/flows/’,

body(‘Parse_JSON’)?[‘name’],

‘/runs/’,

body(‘Parse_JSON’)?[‘run’]?[‘name’]

)

If you run your flow and inspect the outputs of the Compose step, you will see that the URL was effectively generated. Then, by clicking on the link, you will end up on (drumroll) the flow execution page! Isn’t this wonderful?  

 en cliquant sur le lien, vous aboutirez sur la page d’exécution

4. Leverage the power of child flows

It is not all. You can also embed the steps discussed above in a child flow for the benefit of your colleagues, even those who are not experts. That way, you will be able to reuse the function that generates the flow run URL in all your other projects.

What’s the next step? Create the child flow:

1. Create a new flow inside a Dataverse solution

2. Insert a Manual trigger

Add an input parameter (ex. WorkflowOutput)  that will be used to hold the workflow() function output of the parent flow.

3. Processing steps

Recreate the Parse JSON and Compose steps described above but use the input parameter WorkflowOutput as the content source.

4. Respond to Power Apps

End your flow with a Respond to Power Apps or flow step and configure the outputs to send the generated FlowRunUrl and FlowName

The result will look like this:

Done? Now, whenever you create a new flow, you can start by integrating the child flow mentioned above right after the trigger and drop the workflow() function as an input. This will allow you to use the inferred flow run URL later on. See :

utiliser l’URL d’exécution dans la logique de votre flux.

Then, in case of error, you may want to send an email with the link to the execution log to an administrator.  

Finally, the link leads directly to the flow execution log.  

That’s how it is done!