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:

  1. Click the Variables tab in the Designer to open the Variables tab.

    The Variables editor displays a list of the variables and constants that are already defined for the artifact. You can enter a string in the filter field to limit the list to those containing the string. Use the Properties pane to edit the details and event actions for the selected variable or constant.


    Description of webapp-variables-editor.png follows
    Description of the illustration webapp-variables-editor.png

    You will see a message if no variables or constants are defined.

  2. Click + Variable to open the New Variable dialog box.
  3. Choose either Variable or Constant as required.
  4. Type a name for the variable in the ID field and select a type in the Type drop-down list.

    The drop-down list displays the built-in types as well as any custom types that can be applied to the variable.


    Description of page-designer-variables-create.png follows
    Description of the illustration page-designer-variables-create.png
  5. Click Create.

    You can click Create & New to immediately create another variable.

After you create a variable, you can select the variable in the list and edit its properties. You can also:
  • 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.