How to set up global variables in Flows
Last updated
Was this helpful?
Last updated
Was this helpful?
Global variables allow you to store and reuse data across multiple steps within the same workflow.This can be useful for storing configurations, user preferences, or other data that needs to be accessed across flow.
Unlike step-specific variables, which are limited to individual steps, global variables persist throughout the entire flow, enabling greater flexibility and efficiency in workflow automation.
Global variables should be used when you need to store data that needs to be accessed across the flow or if you have multiple branches where you want to update the same value if the user flows through iterations or loops through the same flow. For example, you might use a global variable to store the user preference or storing workflow execution details like retry_count or last_action_timestamp as global variables to track progress.
Unlike the set variables step where you have a UI to create a step-specific variable, in this case you will have to create/set the variable using the advanced json edit function.
To set up a global variable, follow these steps:
In the Flows editor, click on any step or preferably add a “set variables” step and open the advanced JSON edit.
Caveat: This has to be enabled for each org on request and this depends on plan the customer is on.
After getting into the advanced JSON editor, you can proceed to use the below structure to define your global variables.
Please note from the above screenshot we have a step-specific variable as mobilephone and we defined a global variables as mobileglobal.
After you are done defining it. Click on the "Save" button.
Now to refer this in another step you could reference it as {{variables.mobileglobal}} or you could select the variable from the UI picker as shown below.
Here are a few best practices for using global variables:
Use descriptive names for your global variables.
Avoid using global variables for storing sensitive data.
Use a consistent naming convention for your global variables.
Document your global variables so that other users know what they are used for.