Power Automate Tip: How to define constants without having too many variabled declared

 



I have been architecting things and came to my observation that developers are using too many of the variables in the flow which they want to keep the hard-coded values or technically say constants. Declaring/initializing too many variables makes the flow very big and becomes hard to understand. Moreover, it takes a lot of time and effort to add the number of variable components and to name and add comments. This tip will save you from all of these.


So for a quick tip on how we can declare the constants more effectively so that we are not filling the whole screen with the variable declaration

So to do it we can make use of 2 connectors

  1. Compose
  2. Parse JSON

For example, if you want to hardcode the Site URL and some of the list Names we can do something like this...

Step 1: Compose




Step 2: Parse JSON




Step 3: Usage




Conclusion


So these 2 steps will save a lot of your time and effort which you spent in adding the variable connector and defining them. If you want to update any property at any point in time you can also do that using the expression.


Happy Coding..!!
Sumit Kanchan

Comments

  1. Just curious - is there some benefit of using the compose action, over putting the JSON directly into the Content field for the Parse JSON action?

    ReplyDelete
    Replies
    1. Hi, there is not much benefit of it.. you can skip.. it is added for explanation and simplification of the flow. By adding that others can understand what JSON is expected

      Delete

Post a Comment

Popular posts from this blog

Rename Folder using Microsoft Flow / Power Automate in a Document Library in SharePoint Online

Power Automate: How to Add "New Line" to the text in SharePoint multiline text field

How to resolve certificate issue in SharePoint Framework Solution