isset Element
Define and set a user-defined variable.
- name = var_name
Allowed data type: expression or string.
var_name
specifies the name of a user-defined variable. The rules for naming user-defined variables are:- The identifier must start with a letter (a-z, A-Z).
- Any following character can be a letter, number, or underscore.
- User-defined variables are case-sensitive.
- value = var_value
var_value
specifies a value to be stored in the variable. It can be any value.- scope = "session"|"request"|"page"
session
variables are available across multiple requests within a session.request
variables are available for the current internal Salesforce B2C Commerce request. Therequest
variable isn't available for multiple requests, so it isn't available after an interaction continue node.page
variables are available for the current ISML page.
The default scope is the session.
The
pdict
variable is deprecated. Instead, use thescope="request"
variable. Thepdict
variable isn't available for multiple requests, so it isn't available after an interaction continue node.
In B2C Commerce, every user-defined variable is of a specific scope, which defines the visibility and lifetime of the variable. B2C Commerce distinguishes between user-defined variables of the request, pdict, session and page scope.
Scope session means that the variable is accessible to all templates during a particular storefront session. The lifetime of a session variable ends with a session. A session variable can be used in expressions.
The first occurrence of <isset>
in a template declares and sets the variable, there is no other special tag needed for declaration. If the variable already exists, <isset>
resets it to the specified value.
If no scope is set when setting the variable, the scope is set to session.
Example 1
This example shows how <isset>
is used to define and initialize the variable color. The value of color is the string #A0CC99.
Example 2
If a variable was already defined by a former <isset>
tag (first line), a second <isset>
resets the value of the variable (second line).
Example 3
In this example <isloop>
is used to get products from the Pipeline Dictionary.
Example 4
This example shows how <isset>
assigns the value of LoopProduct to Product.
You can also manipulate a value, as shown here:
You can print the value with <isprint>
.
See isremove.
Example 1: Accessing the Page Scope
In this example, isset
sets the decorator template to pt_empty
if the pdict
format attribute is set to ajax and to the pt_account
template if it's not. The DecoratorTemplate variable that is set is accessed by ${DecoratorTemplate}
.