Power Automate Best Practice™: Parse JSON for configuration

Power Automate Best Practice™: Parse JSON for configuration
Variables are not always the answer! Try this best practice.
Variables are not always the answer!

Hello there, friendly flowcrafter! 👋🏻

Here’s a tip from me to make your life inside of Power Automate cloud flows much easier and I think you’ll love it so much that you’ll start using it in almost all of your flows.

Stick around for a Power Automate Best Practice that will change your flow-building ways from this point forward. (Yes, this tip is that good!)

Variables: They’re not all the same!

If you’ve been building flows then you’re familiar with using variables. They can be useful for any number of reasons, but if you stop and think about it, the way we use variables…varies in a given situation, doesn’t it?

Sometimes we use a variable as a way to hold information that changes throughout the lifecycle of our flow.
Sometimes we use a variable so we can set it once and then use that same value in multiple actions.
Sometimes a variable is used when we want to offer a way for users to manage configuration information that we use later.

What do you think is the Power Automate Best Practice for variables?
Should we be using them in each of these cases?

Well, as you’ve probably guessed by the heading of this section, not all of these are the same!

What’s the difference between them? Let’s look at the logical difference.

Variables that change
Are initialized with one value
Used in one or more places
The value of the variable changes during the lifetime of the flow
When the flow finishes, the value is different (usually)
Variables that don’t change
Are initialized with a value that doesn’t change
Used in one or more places
Used for configuration
Or used to DRY your flow

Here we can see clearly two cases where we’d want to use a variable for our flows.

Sometimes they’re used for Configuration and sometimes as Operational Parameters. Both are valid and good uses for variables, but only in the case of Operational Parameters should you be using the variable as it exists in Power Automate.

Let’s explore how and why you’ll want to treat Configuration variables differently.

A quick detour to talk about logical encapsulation
An important concept in programming is the idea of logical encapsulation. This is just a mouthful of syllables to say, “Keep related things together.” The concept is that when you have bits of information which all tend to describe the same thing or that are related in some meaningful way, you’re going to have better results if you can keep all of those items inside a single bucket.

As we are just meat buckets operating in a digital space, our minds work much better if we can setup a place where we know to look for something, that way we don’t have to remember a hundred different things each time we open a flow and try to understand it.

I think every one of us can agree to the following statement: “Simple Power Automate flows are amazing in how they allow me to do complicated things quickly.”

But those of us who know, know. Once a flow grows beyond simple, they can start to get in our way.

Every single action takes up a ton of real estate space on the screen!

So what can we do to both:

a) reduce the amount of space our flows require to view, and

b) logically encapsulate configuration so that it’s easier to manage changes?

Add Parse JSON to replace multiple variables
Add Parse JSON to replace multiple variables
Parse JSON to the rescue!

Power Automate gives us an action called “Parse JSON”. Most people use it to create an object from an JSON where we know what format that object will take.

In this Power Automate Best Practice, you’ll use a Parse JSON block to replace multiple related configuration variables with a single action that provides 100% of your logically encapsulated configuration items!

You can go ahead and delete all those configuration variables, you aren’t going to need them again.

So how does this change our flow? Well, we go from this:

Look at all of those unrelated variables. It'd be a shame if DELETED.
Look at all those stupid unrelated variables up there. It’d be a shame if DELETED

To a much cleaner, and (with a rename) much more logically encapsulated way to manage our configuration:

Oh wow, look! ALL of our configuration is provided by a single action; now that's best practice.
Oh wow, look! ALL of our configuration is provided by a single action.

Easy tips for using this technique

You’ll be creating your own Parse JSON object that holds all of your configuration items.

  • After you’ve created your JSON object, just copy and paste it into the “Generate Schema” window.
  • If you’re using Dynamic Values in your object (this is totally okay to do!), then inside the “Generate Schema” window, you must replace those values with an example of what that Dynamic Value might look like.
  • Rename your Parse JSON step to something like: “Configuration,” or some other name that describes your content and slap that bad boy at the top of your flow.

That’s all about this Power Automate Best Practice today. Happy Crafting!

Blog Response

  • Enter your email address so we can contact you
Nick Hance
Posted on:
I'm a software project rescue specialist who has been rescuing failed software systems since 1999. President of Reenhanced.
Post author