Create Variables
You can create variables and constants in application, flow, and page artifacts, as well as dynamic layouts and fragments. Variables and constants are assigned a scope based on where they are created, and the scope determines where they can be used. When you're deciding where to create a variable or constant, consider where it might be used.
Note though that unlike variables, constants remain the same throughout their scope. You can't change the value of a constant once it has been initialized.
To create a variable or constant in an artifact:
input
, or to add attributes if its type is array
or object
. Here are some key properties:
Property | Description |
---|---|
Type | Identifies the variable type, which could be a specific primitive type (string , boolean , number , and so on); a structured type such as an array or object ; a dynamic type (any ); or a built-in type such as Service Data Provider or Array Data Provider .
|
Input Parameter | Marks a variable as input, indicating that the variable is part of the contract for navigation. Can be set to Disabled (default), Enabled, or Required. Choosing Required implies that the variable must be set to allow navigation to that page, flow, or application.
If you choose Enabled or Required, you can select Pass on URL to pass the input parameter on the URL of the page, flow, or application that you are invoking (by adding You can also enter a Label and Description to show within a |
Default Value |
Specifies the default value to initialize a variable. This property can be an expression or a static value. For string-type variables, you can use the Design Time tab in the Properties pane to display a custom component for setting the variable's Default Value. For example, if you want to use a color picker component instead of the default text field to select a color, select Color as the Subtype in the Design Time tab. If you want to use an enumerated list, select Enum Values as the Subtype and add your enumerated list, which then appears as a drop-down menu for the Default Value: The properties you see in the Design Time tab will depend upon the variable's type, and the Subtype property you select. For example, if Date is selected as the Subtype, you'll also see fields for setting Minimum and Maximum limits. Selecting Color, Date, Date Time, Enum Values, or Time Zone as the subtype will display custom components for the Default Value. If you select any of the other subtypes, you'll see a text field for entering the Default Value. |
Dirty Data Behavior | Tracks changes in a variable's state, marking it as "dirty" when its current value differs from its initial value. See Track Variables to Detect Unsaved Changes. |
Persisted | Sets the lifespan of the variable to be longer than the page, for example, when you want to keep an authorization token for the duration of a session. This property ensures that even if the page is refreshed, the token will still be available throughout the session. Can be set to:
|
Rate Limit | Limits how often the onValueChanged event is triggered, which is whenever the variable's value changes. By default, the event listener that "listens" for this event waits for the value (specified here in milliseconds) to expire after all changes stop to fire the event.
You can trigger an action chain when a variable's value changes by adding a listener for the |
Now that the variable is defined, you can bind it to a component to display its data. See Bind a Component to Data.
Once a variable is used in an application, you can view its usage information under Usages in the variable's Properties pane. You can see which pages access the variable and click links to readily navigate to those pages.