Power Automate - Constant Values - Avoid Initialize Variable actions
Problem:
In my flow, I have 10 constant values. I am using these constant values from many actions in the flow. To define each constant value in the flow, I used "Initialize Variable" action and stored the value. So for 10 constant values, I have created 10 "Initialize Variable" actions as shown below:
All the above "Initialize Variable" actions contains constant values ONLY.
Every time, when the flow executes, it send 10 API calls for these variable initialization.
Solution:
To improve the performance by reducing the number of API calls to initialize the constant values, you can use below method:
Step 1: Use Compose method and create a JSON object with all constant values as below:
Step 2: Use "Parse JSON" action to parse the output of above Compose action
Step 3: Now, you can start using the constant values directly from other actions
Limitations:
The above approach will not work if you want to change the values of the constant.
Regards
Krishna Rachakonda
Comments
-
Power Automate - Constant Values - Avoid Initialize Variable actions
Older post but I think it might be beneficial to my current flow which is quickly becoming a beast. Wondering if anyone could perhaps shed some light on the OP's limitation comment:
"Limitations:
The above approach will not work if you want to change the values of the constant."
In my current flow I am initializing several variables, both String and Integer, that will eventually be updated via Set variable actions. Is the use of these set actions the limitation the OP is referencing in their limitation comment?
Thanks
*This post is locked for comments