Managing session variables

Session variables panel

The view for managing session variables is the Session variables. To open it, select the option in the left menu Session variables. On the right side of the panel title bar there is a magnifying glass icon that allows searching the list of variables.

Illustration 1. The "Session variables" panel

Adding a new session variable

Adding a new session variable is done by pressing the Add session variable.

In the new row added at the very top of the panel we fill in:

  • Mid - variable key

  • Default value - constant value of the variable

  • Service id - after attaching the session variable to a service, the name of that service will appear here

  • Output parameter - if the session variable will be an output parameter of the service, it will be indicated here

  • Exposed - indicate whether the session variable should be passed to the client explicitly. This option allows using the session variable in conditional expressions and formatters executed on the client side. If the session variable has the box unchecked, it is not sent to the client.

  • Gtm

  • GTM tag - name of the GTM tag

  • Statistics - enabling the option to send the variable value to statistics.

Illustration 2. Row for creating a session variable

After leaving the name field, the variable is created. If no name is defined for the variable, the system will automatically assign the value "empty" or a copy of that value if it already existed.

Editing an existing session variable

To edit an existing variable, simply click in the Mid column and change the value.

Definition of service output

A session variable can serve as a place to store the result of executing a service defined within any page of the current application.

We define mapping of the variable to the appropriate service output field in the Page servicespanel, which we open by clicking the Page services:

Illustration 3. List of services available on the application, displayed after clicking the "Page services" button

After the list of services available for the application appears, we look for the appropriate service, then reveal its details by clicking the option on the right side of the panel Show details. Mapping the service output to a variable will be possible after clicking Output parameters in the displayed details:

Illustration 4. Expanded details for PageService1

In the output parameters tab we click the Add parameter — this will display a row in which first, in the Application componentcolumn, we choose the session variable for which we want to map the output, and then in the Output parametercolumn, we indicate the appropriate output:

Illustration 5. In the "Output parameters" tab a session variable has been selected, for which an output parameter still needs to be chosen

After correctly attaching the service to the variable, its properties will contain information about the attached service and the selected output parameter:

Illustration 6. In the session variables panel, for a variable that has a service attached, its name is in the "Service id" column, and next to it the output parameter from the service

Deleting a session variable

A session variable is deleted by selecting the trash icon available when hovering over the row of that session variable. Attempting to delete a session variable used in an artifact (e.g., as an input parameter to a service or listening to a variable) will result in an informational message being displayed:

Illustration 7. Tooltip with information about the inability to delete the session variable

Using a session variable to set the initial value of a component

To use a session variable to set the initial value of an element, perform the following steps:

  • select the component

  • in the list of available properties search in the Interactions section for the property DATA SOURCE FROM ANOTHER FIELD

  • after clicking in Choose component or constant we can choose the mid of the session variable that will serve as the default value of that element,

  • additionally, it is necessary to add listening to the variable according to the instructions in: Listening and clearing

Using a session variable to retrieve a component's value

For the session variable we choose the EchoService service added on the application's page.

Examples of using a session variable

  • Using a session variable in a condition: getValue("@zmienna1")=="Y" where zmienna1 is the variable name

  • Using a session variable in a Label component: The current value of the variable is ${zmienna1} where zmienna1 is the variable name

Demo application: demoSessionVariables

Last updated

Was this helpful?