Power Automate Best Practice™: Parse JSON for configuration
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!)
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?
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
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.
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?
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:
To a much cleaner, and (with a rename) much more logically encapsulated way to manage our configuration:
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!