Ask AI
Skip to main content

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, UserName or CurrentDate.
  • 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

  1. Storing a User's Name after Login:

    • Inputs:
      • Variable name: LoggedInUserName
      • Variable 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".
  2. Setting a Discount Percentage for a Promotion:

    • Inputs:
      • Variable name: DiscountRate
      • Variable value: 0.15 (representing 15%)
    • Result: A global variable named DiscountRate is created with the value 0.15. This can be used in calculations across the application, for instance, to show discounted prices or apply discounts in an order summary.
  3. Tracking the Current Date for Reporting:

    • Inputs:
      • Variable name: ReportDate
      • Variable value: 2023-10-27 (a DATE type)
    • Result: The application's global state now includes ReportDate set to October 27, 2023. This variable can be displayed on reports, used in date-based filtering, or for timestamping events.