Managing session variables

Session Variables Panel

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

Figure 1. "Session Variables" panel

Adding a new session variable

A new session variable is added by pressing the button 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 specified here

  • Exposed - we mark whether the given session variable is to be passed to the client explicitly. This option allows the session variable to be used 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's value to statistics.

Figure 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 column Mid and change the value.

Definition of service output

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

The mapping of the variable to the appropriate service output field is defined in the Page servicespanel, which we open by clicking the button Page services:

Figure 3. List of services available in the request, displayed after clicking the "Page services" button

After the list of services available for the request appears, we look for the appropriate service and 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:

Figure 4. Expanded details for PageService1

In the output parameters tab, click the button Add parameter — this will display a row in which first, in the column Request component, we select the session variable for which we want to map the output, and then in the column Output parameter, we indicate the appropriate output:

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

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

Figure 6. In the session variables panel, for the variable with an attached service, its name is in the "Service ID" column, and next to it is the service output parameter

Deleting a session variable

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

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

Using a session variable to define a component's initial value

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

  • select the component

  • in the list of available properties, find the property in the Interactions section DATA SOURCE FROM ANOTHER FIELD

  • after clicking on Choose component or constant we can choose the MID of the session variable that is to be used as the default value of this element,

  • additionally, you need to add a listener for 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 select the EchoService service added to the request page.

Examples of using a session variable

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

  • Using a session variable in the Label component: Current value of the variable is ${variable1} where variable1 is the name of the variable

circle-exclamation
circle-info

Demo request: demoZmienneSesyjne

Last updated

Was this helpful?