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.
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.
- Save the Flow Run URL in a Dataverse record for further investigation.
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!
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.
3. Build the URL
You have reached the final step – developing a URL in a similar format as this one:
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:
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?
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 :
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!
Read also :
This article is an initiative of our expert David Rivard.
Want to find out more?