isif Element

Create conditional template code and control the flow of business logic.

condition = if_expression

Allowed data type: string or expression.

if_expression evaluates to a boolean value. If the <isif> condition is true, the system executes the code immediately following the <isif> tag, ignoring the enclosed <iselseif> and <iselse> tags. If the <isif> condition is false, the system ignores the code immediately following the <isif> tag, and then tests each <iselseif> condition in order. When the system finds a true <iselseif> condition, the system executes the code immediately following the <iselseif> tag and ignores any remaining <iselseif> and <iselse> tags. If all <iselseif> conditions are false, the system executes the code following the <iselse> tag.

The <isif> tag group lets you create conditional programming constructs using custom tags.

<isif> and its supporting tags, <iselseif> and <iselse>, are some of the most commonly used tags. They contain no business logic, just the conditional visualization of data.

Every <isif> tag must have a matching </isif> tag. You can use any Salesforce B2C Commerce script expression as a condition for the <isif> tag. In particular, you can use local variables, Pipeline Dictionary variables and any functions within those expressions.

<iselse> and <iselseif> are optional. You can use as many <iselseif> tags as needed in an <isif> statement, but you can only use one <iselse>, which must always be the last tag within an <isif> group.

A conditional expression should typically return a boolean which is interpreted appropriately. If condition expression evaluates to non boolean and is not null, it's interpreted as true. When it evaluates to null it's interpreted as false.

This example shows how to toggle continuously between three different colors for the rows of a table. The current color is stored in the user-defined variable, color.