Automation KIT
Dataverse Desktop Flow Power Automate
Manish Solanki  

Extend Automation KIT to capture transaction count for desktop flows

Use Case

Automation KIT is a set of tools that accelerate the use & support of Power Automate for desktop for automation projects. One of its limitations is that it does not provide the number of transactions processed by a Power Automate Desktop flow.

Prerequisites

Each desktop flow should return the count of transactions in output parameter ‘TransactionCount’:

Solution

The details of desktop flow runs are stored in ‘Flow Session Trace‘ table in “Main Environment“. So, we will create a new integer column in that table that stores the transaction count for each flow run.

As I have installed “Managed” solution for Automation KIT so I need to create a new solution in “Main Environment” to add a new column in the table of managed solution.

Go to Main environment, create a new solution “Automation CoE Extension” and select “Add existing” option from top command bar and choose “Table” from the sub menu:

Search for “Flow session trace” table & click “Next” button:

Check ‘All objects’ box. Press ‘Add’ button to add the table:

Following that, go to “Table -> Flow Session Trace -> Column” & click ‘New Column’ from the top command bar:

Enter the display name, let’s say “Transaction Count” and set its type as ‘Whole number’:

Next, go back to the solution & create an automate flow that will update the transaction count column in the Dataverse table:

Choose “When a row is added, modified or deleted” as trigger for new flow. Select ‘Flow Session Traces’ table from the dropdown. We will apply filter condition to trigger flow when desktop flow succeeds.

Query used for ‘Filter rows’ parameter:

autocoe_overallstatus eq 'Succeeded'

Here, ‘autocoe_overallstatus‘ is the logical name of the ‘Overall Status’ column in ‘Flow Session Trace’ table.

Next, add “List My Environments” action to get the list of environments (for which you have the access) using admin connector:

Add “Filter array” action to filter the environment object which is stored in the Dataverse record. Pass the value object from the output of previous action as its input:

Click ‘Edit in advanced mode’ button & enter the query in the textbox:

@equals(item()?['name'], triggerOutputs()?['body/autocoe_environmentid'])

Here is the catch, we will fetch the value of output parameters from standard ‘Flow Session’ table stored in the Satellite environment (where flow runs) using the record Id. The ‘Flow Session’ is a standard table that holds the details of desktop flows along with its output in blog (file type).

Add “Download a file or an image from selected environment” action to fetch output of a desktop flow record from satellite environment:

Expression used for ‘Environment’ parameter:

first(body('Filter_array'))?['properties']?['linkedEnvironmentMetadata']?['instanceUrl']

In ‘Table name’ parameter, choose ‘Enter custom value’ from dropdown & enter ‘flowsessions’ as a plain text. Dynamically, pass the value of ‘Flow Session Id’ from the trigger:

Select ‘Enter custom value’ from dropdown for ‘Column name’ parameter & enter ‘outputs’ as plain text in the textbox.

Add “Compose” action to store the output of desktop flow as JSON object. Enter an expression in the expression box to decode the base64 content of the file column and convert to JSON object:

json(decodeBase64(body('Download_a_file_or_an_image_from_selected_environment')?['$content']))

Finally, add “Update a row” action to update the count of transaction from the output parameter of same desktop flow from standard ‘Flow Session’ table in the Satellite environment. Select ‘Flow Session Trace’ from the dropdown in ‘Table name’ parameter. Dynamically, pass the record identifier from the trigger action:

Scroll down, locate ‘Transaction Count’ column and enter an expression to set the value of output parameter for a desktop flow fetched from Satellite environment.

outputs('Compose')?['TransactionCount']

Output

‘Flow Overview’ report before customization:

‘Flow Overview’ reports after customization:

Conclusion

We can enhance ‘Flow Overview’ report by extending Automation KIT to include number of transactions processed by desktop flows. This can be achieved by adding a custom column in ‘Flow Session Trace’ table & using Dataverse and admin connectors.

References

Here is the documentation link to know more about Automation KIT: Overview of the Automation Kit – Power Automate | Microsoft Learn

Leave A Comment