Tip #1447: Use Parse JSON for settings

I often see makers declaring multiple settings in a Power Automate flow using a single variable per setting.

The screenshot shows a sequence of three configuration steps in a Power Automate flow, each labeled with the action "Initialize variable." The first step initializes an integer variable named "Last Month" with the value 6, indicating the last month of the financial year. The second step initializes a string variable named "Default Currency" with the value "AUD," setting the Australian Dollar as the default currency. The final step initializes a float variable named "Maximum Writeoff" with the value 499.99, which could represent a maximum allowable write-off amount in the given financial context. Each step is represented with a distinct color code, suggesting a logical progression in the flow.

For complex flows, it can quickly get out of hands as variables must be declared on the top level; they cannot be nested or even scoped. An environment variable per each setting, you say? Way to make friends with the deployment admins!

Instead, use Parse JSON action and keep your flows compact by combining all related settings in one neat JSON object.

The screenshot displays a dialog box from Power Automate for setting properties in a 'Parse JSON' action. The content section includes a JSON object with three properties: "LastMonth" with a value of 6, "DefaultCurrency" set to "AUD", and "MaxWriteoff" set at 999.99. Below the content box, the schema section is partially filled out with JSON schema definitions corresponding to the above properties, indicating "LastMonth" as an integer and "DefaultCurrency" as a string. There is also a button to "Generate from sample" to create the schema based on a sample JSON content.

Accessing settings after that is intuitive and self-explanatory. And you get a Body as a bonus.

The image is a screenshot of a dynamic content selector within a Power Automate workflow. The panel shows a list of variables and settings from the workflow, indicating where they can be used as dynamic content in subsequent actions. Variables displayed include "Maximum Writeoff," "Default Currency," and "Last Month." Under the settings, items such as "Body," "LastMonth," "DefaultCurrency," and "MaxWriteoff" are available for selection. The interface elements such as search bar, information, and close icons, along with the expansion arrows for each section, suggest that the user can interact with this panel to insert these dynamic values into other parts of the workflow.

6 thoughts on “Tip #1447: Use Parse JSON for settings

  1. No Images says:

    Posted images are not rendering for me

    • We’re experimenting with webp format that is better than either jpg or png. I wonder what kind of browser are you using, user ‘No Images’. According to https://caniuse.com, webp is rendered in 98.5% of all tracked browsers so I suspect you are on IE, Safari < 14, or some obscure browser. Time to upgrade?

      • Yes Images says:

        Browsing this site on Safari 15.6.1 on an older Mac Mini running Catalina. The images don’t render, however they do render on an iPhone and on the same Mac Mini using Chrome. So… I’ll stick to what is working (going to try to restart Safari and check again). Thanks for the reply 🙂

        • Ah yes, anything before Big Sur is a no go, don’t think restrart is going to fix it. (I still have a Macbook Air lying around somewhere stuck on Mountain Lion 😀 )

          I think we’ll stick with webp as it does produce better files especially with transparency, x2-3 smaller than png!

  2. Doug Riley says:

    This is a very clever idea! However, it is really only useful for static data used in the flow – like default values, testing flags, etc. – but still helpful.

    I wish MS would allow us to put variable initialization inside of a Scope – that would really cleanup my flows! Seems like such a simple ask :-).

    • It is definitely for static data like settings even though you can manipulate objects using functions like addProperty, etc. Scoping for variables probably won’t ever be implemented but what I would like to see is a separate action/box/scope/side panel for variable definitions. I can then tuck away all my variables in one place and keep it out of sight.

Leave a Reply

Your email address will not be published. Required fields are marked *