Power Platform administrators, do you automate processes in your app using Power Automate? Do you know how to monitor flow runs and inform users of their status? Here is how to do it.

 

The emergence of the Power Platform and flows allows for increasingly complex operations to be performed across multiple systems. A single click can trigger a string of actions. From the point of view of the user, however, it can be difficult to monitor flow runs. The flows are triggered, but the user has no way of knowing what is going on in the background. As a result, to access error information, you have to open the Power Automate app to see the list of flow runs.

Moreover, you need to know which flows have been triggered.

 

Finding out flow status: essential for users

Your colleague Gilbert is in charge of billing. He executes complex actions using a Power Automate-based application that you designed. However, once an action is triggered, he has no way of knowing the status of the flow runs.

  • Was the action successful? 
  • Is it still processing? 
  • Did an error occur when the action was initiated?

It is as though the system user is throwing a bottle into the sea without knowing if it will reach its destination. So, did it run into problems? Did it hit a rock and break? In other words, the user is launching a rocket without knowing if it took off correctly, if it reached its destination, or if it exploded mid flight.

 

How to monitor flows?

So, how do you monitor these operations (or flows) and provide the user with a visual of flow runs? Basically, the idea is to create an entity that will gather flow information. This way, the user knows what is going on within the context of a model-driven app.

Here are the steps that allow you to monitor flow runs. You can also send the user updates throughout the process.

Donc, voici les étapes qui permettent de garder la trace des traitements déclenchés. De plus, elles permettent de présenter à l’utilisateur un message à chaque étape du processus. 

When the flow run is processing:

Power Automate - Treatment in progress

 

When the flow run is finished:

Power Automate - Treatment completed

 

If the flow run fails:

Power Automate - Treatment in error

 

The ingredients

To achieve this outcome, you will need the following:

  • An entity to monitor flows;
  • A cloud flow to enable business process flows (conditions, actions, etc.);
  • JavaScript to display an alert on the status of the request within the model-driven app.

 

1. Create an entity for running flows asynchronously

Start by creating a new entity called “Requests.” This entity will be the basis for monitoring flow runs.

 

a. First, create fields for the following information:

  • Status of the request (active, processing, success, error);
  • Environment: EnvironmentId;
  • Flow ID: FlowId;
  • Run ID: RunId;
  • Flow Run
    • The URL field is calculated using this formula: https://flow.microsoft.com/manage/environments/EnvironmentId/flows/{FlowId}/runs/{RunId}. 

 

b. Next, create a request when the flow is triggered

When the user triggers a flow (e.g., Gilbert clicks on “Bill”), use a workflow or a plugin to create a request with the parameters needed for the process.

 

 

2. Create a cloud flow to process the request

Now create a cloud flow to process the request.

 

a. The flow is triggered when the request is created

The flow is triggered when the request is created or updated. So, just filter the trigger based on the status and type of the request.

b. Now add a Scope step to group the processing of the request

Within the scope, add a Parse JSON step. Use the workflow() function to retrieve the cloud flow information.

Parse Json 

c. Update the request to add the flow information and indicate that it is processing  

  • Environment Name 
  • Flow ID 
  • Run ID
  • Status: Processing 

 

d. Add flow steps

The content of this step depends on the type of flow run. For example, you could run a flow in Power Automate by calculating the amount of each invoice and sending the results by email.

 

e. Add a step to update the status and show that the flow was successful

f. Add a parallel branch to show whether the flow is in error

Click on Add a parallel branch.

 

In the branch, update the status of the request to Error.


 

Set Configure Run after to update the status of the request if the process fails.

 

 

3. Create a JavaScript in the model-driven app

Finally, use JavaScript to display an alert based on the status of the request.

 

Now, when a flow is triggered, the user will be notified that the flow is processing.

 

The user will also be notified when the flow is successful.

 

Finally, the user will be notified if a flow is in error.

 

If the flow is in error, click on Request Associated.

 

Then, click on the flow URL to access the Error Details.

 

Conclusion

In a few simple steps, you can monitor flow runs in the app and send the user updates throughout the process. This way, your users can keep track of what is happening and easily report errors.

Finally, you can even create a dashboard to display statistics on flow runs and failures.


This article was written by our expert Abdoul Baldé.

 

See also

Infer the Flow Run URL

Want to find out more? 

Our team can support you with personalized advice, training or new solutions tailored to your needs. Contact one of our experts to optimize the use of your technologies and your daily processes.