Simplify Flow Settings With A Config File In Power Automate Desktop

Simplify Flow Settings With A Config File In Power Automate Desktop

A Power Automate Desktop config file holds configuration data used by a desktop flow. It allows the developer to store settings separately from the automation logic. Configuration data remains constant throughout all flow runs. If it becomes necessary to update the config file, a developer can do so without changing the automation itself.

Table of Contents
• Create A JSON File On The MachineRead The Config File In Power Automate DesktopConvert JSON Config File To A Custom ObjectSelect A Value In The Config Custom Object




Create A JSON File On The Machine

The Power Automate desktop config file we will build is a JSON file that stores all of the necessary flow settings. Open Windows Explorer, make a new folder for the Sales Tax Report automation and create a text document file (txt) inside the folder. Rename the document and change the extension to SalesTaxReport-ConfigFile.json.



Open the config file in a text editor such as VSCode or Windows Notepad.



Then copy and paste this JSON object into the JSON file. A JSON object must be structured as a series of key-value pairs within curly brackets. The JSON below includes string, number and boolean values. We can also use objects, arrays and nulls as values though they are less common.

{
    "File Location": "C:\\Power Automate\\Sales Tax Report\\All Company Sales.xlsx",
    "Business Owner Email": "[email protected]",
    "Sales Tax Rate": 5.5,
    "Enable Notifications": true
}




Read The Config File In Power Automate Desktop

The first action a Power Automate Desktop flow performs should be to get the configuration data and stores the values in a custom object (variable). Open Power Automate Desktop and create a new flow.



Add a read text from file action and populate the file path with the JSON config file path. Store the content as a single text value. Change the variable produced to ConfigFileContents.




Convert JSON Config File To A Custom Object

To use values stored in the config file we need to convert the JSON string into a custom object variable. Insert the convert JSON to custom object action into the flow. Update the variable produced to ConfigValues.



Write this expression in the JSON field of the action to load the JSON string.

%ConfigFileValues%


When we run the desktop flow we can see the configuration data loaded into the ConfigValues variable.




Select A Value In The Config Custom Object

Now that the config file values are stored in a custom object we can use them in a desktop flow. For example, we could show the file location in a message box. Add a display message action to the flow with the title “Test Message.”



Write this expression in the Message To Display field to show the file location. The “key” written inside of the square brackets tells Power Automate Desktop which value retrieve.

%ConfigValues['File Location']%


Save the flow and press Play. A message box appears with the config file value for the file location.





Questions?

If you have any questions or feedback about Simplify Flow Settings With A Config File In Power Automate Desktop 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.

Matthew Devaney

Subscribe
Notify of
guest

2 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Josh
Josh
2 months ago

Matt, is there a way for me to contact you with questions about automating tasks on windows? I’m just beginning and I feel like my questions may be simpler than I’m making them out to be, but I’m pretty much wanting to make my wordload more efficient by automating mundane and repetative tasks. There’s probably software out there that would help but I have no idea.

Thanks

Gennady
Gennady
1 month ago

Hey Matthew,
thanks for a great article, which hopefully will be my starter for using Power Automate Desktop 😊 Is there also a “Parse JSON” command in the desktop, so I can process the more complex JSON objects and read their properties without having to write the quoted strings? 🙂