Create Variables in Artifacts
You can create variables, including constants, in application, flow, and page artifacts. They are assigned a scope based on where they are created, and the scope determines where they can be used. When you are deciding where to create a variable or constant, consider where it might be used.
Each variable or constant is required to have a unique name (Id) and a type. When you create one, you must specify one of the built-in types or a custom type. After you create a variable or constant, you can edit its properties and attributes in the Variables editor, for example, to identify it as an input
, or to add attributes if its type is array
or object
.
You can also use a variable to trigger an action chain when its value changes. You can use the Events tab in the Variable Information pane to add onValueChanged
event actions and specify the action chain the change will initiate.
Unlike variables, constants remain the same throughout its scope. You can't change the value of a constant once it has been initialized.
To create a variable or constant in an artifact:
- Use the Events tab in the Properties pane to add event actions.
- Use the Design Time tab in the Properties pane to choose a custom component to set a variable's Default Value in the General tab. For example, if you want to use a color picker component instead of the default text field to select a color, select the Color subtype in the Design Time tab. The General tab will display custom components when you select any of the following subtypes: Color, Time Zone, Date Time, and Date. If you select any of the other subtypes, you'll still see a text field for entering the Default Value in the General tab.
You can also view usage information under Usages (for example, to see which pages access the variable). Click a usage to readily navigate there.
Tip:
A shortcut to create variables for a specific type is available on the Types editor. To do this, select a type in the Types tab, then right-click and select Create a variable.