---
schema_version: "1"
id: 2a89af84d97df2f284c386fc751731033d487fef838ce5f61610d22cd10e2ffc
title: isset Element
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/commerce-cloud/b2c-commerce/guides/isml/b2c-isset.md
canonical_url: https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/b2c-isset.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: d9dd4eaad3b4b39a36c6c0c9a7b65dd18b1a393259a5ccf1394bd7aa92a890df
products:
  - Composable Storefront
  - Salesforce APIs
---
# isset Element

Define and set a user-defined variable.

## Syntax

```
<isset
  name  = var_name                   \\required
  value = var_value                  \\required
  scope = "session"|"request"|"page" \\required
/>
```

- 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. The `request` 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 the `scope="request"` variable. The `pdict` variable isn't available for multiple requests, so it isn't available after an interaction continue node.

## Purpose

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.

**note:** If no scope is set when setting the variable, the scope is set to session.

## Examples: Using Isset to Create a Custom Variable

Example 1

This example shows how `<isset>` is used to define and initialize the variable color. The value of color is the string #A0CC99.

```
<isset name="color" value="${'#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).

```
<isset name="counter" value="${0}" >
<isset name="counter" value="${counter + 1}">
```

Example 3

In this example `<isloop>` is used to get products from the Pipeline Dictionary.

```
<isloop iterator="${pdict.ProductPagingModel.pageElements}" alias="LoopProduct" begin="0" end="2">
```

Example 4

This example shows how `<isset>` assigns the value of LoopProduct to Product.

```
<isset name="Product" value="${LoopProduct}" scope="request">
```

You can also manipulate a value, as shown here:

```
<isset name="brandsPerCol" value="${Math.floor(numOfBrands/4) + 1}" scope="page">
```

You can print the value with `<isprint>`.

See [isremove](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/b2c-isremove.md).

## Examples: Accessing Custom Variables

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}`.

```
<isset name="DecoratorTemplate" value="account/pt_account" scope="page"/>
<isif condition="${pdict.CurrentHttpParameterMap.format.stringValue == 'ajax' || pdict.CurrentHttpParameterMap.pwr.stringValue == 'true' || pdict.CurrentHttpParameterMap.source.stringValue == 'search' || pdict.CurrentHttpParameterMap.source.stringValue == 'quickview' || pdict.CurrentHttpParameterMap.source.stringValue == 'cart'}">
	<isset name="DecoratorTemplate" value="util/pt_empty" scope="page"/>
</isif>

<isdecorate template="${DecoratorTemplate}">
```
