Adding Data variables

The Studio provides you features to add Data and Custom JavaScript data as variables. You can then use the variables and bind them to controls or use them for creating rules and formulas. Data as a variable feature can be used to create variables that are of type persistent and non-persistent in nature.

Adding variables

To add a new variable, under Studio Console click Data, and click +New.
You will be provided with a dropdown with two options to create new data as variables-

  1. String Builder
  2. Custom JS

Data as variable

  1. Provide a name for the variable and select the type as Persistent or Non-Persistent.

    • The Persistent variables are those which retain their values across multiple Microapp launches. So if you exit any MicroApp and reopen it later, the persistent variables would get the last saved value. For example, you can add variables to maintain the login id and password values across screens, its value would not be reset, and they would get the last saved values.

    • The Non-persistent variables would be those that would not retain state across MicroApp launches. Hence they cannot be used for scenarios where you want to restart your MicroApp multiple times. However, the non-persistent variables would not lose their values in multiscreen scenarios. So we are using both types for the sake of this example.

  2. You will be provided with a JS/SQL editor. This will support the binding of raw JSON data, keywords, control binding, querying JSON with AlaSQL support, and more. You can provide static data or can write formulas to curate certain data needed for your microapp.

  3. Click Save and your Data as the variable will be added.

You can now use/bind these variables anywhere in your microapp, including bind data section actions flow, rules, conditions, into another variable, and more.

Custom JS as variable

  1. Select Custom JS option from the dropdown.

  2. It will open a window to write Custom JavaScript data as variable. Select type as Persistent or Non-Persistent.

  3. Provide input parameters. These are passed as arguments to the JavaScript function you define. It is important to ensure that the right data type is used. Ensure that you add a test value for the script. You can read more about custom JavaScript here. The output of this JS Code will be the value of this data variable.

  4. Click Test & Save.

  5. You will see that your Custom JavaScript data is added as a variable.

You can now use/bind these variables anywhere in your microapp, including bind data section actions flow, rules, conditions, into another variable, and more.