Add global variable
Function: Add global variable
Add a global variable to the state of the application. This allows you to store and reuse information throughout your application, making it accessible on any page or in any action. When you set a global variable, it can automatically replace placeholders (like \{\{FIRSTNAME\}\}) on your pages with the variable's value.
Input
- Variable name (STRING, Required): The unique name you want to give to your global variable. This name should be unique across your entire application to avoid conflicts. For example,
UserNameorCurrentDate. - Variable value (VARIABLE, Required): The actual data or content you want to store in this global variable. This can be text, a number, a date, a true/false value, or even a more complex object.
Output
This action does not produce a direct output that needs to be captured. Its primary effect is to update the application's internal state by adding the new global variable, making its value available for use throughout your application.
Execution Flow
Real-Life Examples
-
Storing a User's Name after Login:
- Inputs:
Variable name:LoggedInUserNameVariable value:John Doe
- Result: The application now stores "John Doe" as
LoggedInUserName. Any text field or display element configured to show\{\{LoggedInUserName\}\}will automatically update to "John Doe".
- Inputs:
-
Setting a Discount Percentage for a Promotion:
- Inputs:
Variable name:DiscountRateVariable value:0.15(representing 15%)
- Result: A global variable named
DiscountRateis created with the value0.15. This can be used in calculations across the application, for instance, to show discounted prices or apply discounts in an order summary.
- Inputs:
-
Tracking the Current Date for Reporting:
- Inputs:
Variable name:ReportDateVariable value:2023-10-27(a DATE type)
- Result: The application's global state now includes
ReportDateset to October 27, 2023. This variable can be displayed on reports, used in date-based filtering, or for timestamping events.
- Inputs: