Power Automate Desktop Config File Stored In Dataverse Table
A Power Automate Desktop config file can be stored directly on a machine or in a Dataverse table. A config file allows the developer to store settings separately from automation logic. The advantage of using a Dataverse table is the flow settings will be associated with the Power Platform environment where the flow is run. As a desktop automation is promoted to Dev, Test and Production environments the flow will automatically use the config file for the proper environment.
Table of Contents
• Get Config File Values From A Dataverse Table
• Convert Config File Array Data Into A JSON Object
• Add A Config File Input Variable In Power Automate Desktop
• Use The Config File Values In Power Automate Desktop
• Use The Config File Values In Power Automate Desktop
• Test Loading Config File Values Into A Desktop Flow
Create A Config File Dataverse Table
We will start by creating a Dataverse table to store the config file values used by one or more flows. Add a new table named PAD Configuration Value.
Then add the following columns to the table:
- Flow Name (Text)
- Name (Text)
- Value (Text)
- Variable Type (Choice: Text, Number, Boolean)
Populate the PAD Configuration Values table with the following data. The flow name identifies which flow the config file data is used for. The name field identifies the config value and should be unique for each flow name. Values are all stored as text in the Dataverse table and will be converted to the proper variable type during the flow run.
Flow Name | Name | Value | Variable Type |
Sales Tax Report | Business Owner Email | [email protected] | Text |
Sales Tax Report | Enable Notifications | TRUE | Boolean |
Sales Tax Report | Excel File Location | C:Power AutomateSales Tax ReportAll Company Sales.xlsx | Text |
Sales Tax Report | Sales Tax Rate | 5.5 | Number |
Get Config File Values From A Dataverse Table
The desktop flow will be triggered in the cloud and run in attended mode. We want to retrieve the config file values stored in Dataverse and load them into a desktop flow input variable. Create a new cloud flow and add the following actions. Insert the Run A Power Automate Desktop flow action after we have built the desktop flow.
- Dataverse – List Rows
- Data Operations – Select
- Data Operations – Compose
- Power Automate Desktop – Run A Power Automate Desktop Flow
List rows: PAD Configuration Values
Select Columns:
md_name, md_value, md_variabletype
Filter Columns:
md_flowname eq 'Sales Tax Report'
Select: Config Values
Map Key:
item()?['md_name']
Map Value:
if(equals(item()?['[email protected]'],'Number'),float(item()?['md_value']),if(equals(item()?['[email protected]'],'Boolean'),bool(item()?['md_value']),item()?['md_value']))
Compose: Config Values Object
Inputs:
first(json(replace(string(body('Select:_Config_Values')),'},{',',')))
Convert Config File Array Data Into A JSON Object
To understand what the cloud flow is doing it is necessary to look at result of each action. The data retrieved by the List Rows action returns PAD Configuration Values in an array. This array includes many extra columns.
Then we use the Select action to transform the config file array into a series of key-value pairs.
And finally we convert the array into an object. This object will have the same structure as the custom object we create in Power Automate Desktop to hold config values.
Add A Config File Input Variable In Power Automate Desktop
We want to pass the config file values from Dataverse into Power Automate Desktop. Open Power Automate Desktop and start a new flow. Create a new input variable named inpConfigValues with the data type Custom Object.
Use the following placeholder values inside of the custom object to define its structure.
Alternately, you can also copy and paste this JSON into the Power Automate Desktop editor to define the custom object.
{
"Excel File Location": "C:\temp\Sample.xlsx",
"Business Owner Email": "[email protected]",
"Sales Tax Rate": 0,
"Enable Notifications": false
}
Use The Config File Values In Power Automate Desktop
The config file values passed from the into Power Automate cloud flow can now be used by the desktop flow.
Add a display message action to the desktop flow with the title Config Values Test.
Use this code in the message to display field. The key inside of the square brackets after the variable name tell Power Automate Desktop which property of the custom object to target.
File Location:
%inputConfigValues['Excel File Location']%
Test Loading Config File Values Into A Desktop Flow
We’re done building the cloud flow and the desktop flow. Give it a test run to make sure it works.
The configuration values appear inside of the run a flow built with Power Automate Desktop action.
And the desktop flow makes a message box appear with the path to the file location.
Did You Enjoy This Article? 😺
Subscribe to get new Power Apps & Power Automate articles sent to your inbox each week for FREE
Questions?
If you have any questions or feedback about Power Automate Desktop Config File Stored In Dataverse Table please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.