Salesforce B2C Commerce JavaScript Expressions in ISML

To simplify coding, we prefer that you use B2C Commerce JavaScript expressions within ISML templates.

Examples

This prints the product display name from the Pipeline Dictionary:

<isprint value="${pdict.Product.displayName}"/>

The product SKU is:

${pdict.Product.sku}

This checks if there are any items or gift certificates in the cart (as entered by the customer):

<isif condition="${empty(pdict.CurrentForms.cart.items) && empty(pdict.CurrentForms.cart.giftcerts)}">
<!--- empty basket --->
<div id="infoBox">Your shopping cart is empty.</div>	
<iselse>

The Empty Operator

Empty has a particular significance when accessing an object, as follows:

Operator Purpose
empty()

Returns true if the object is empty. Empty is defined as:

  • null
  • undefined
  • a string with zero length
  • an array with no elements
  • a collection with no elements
Note: If the object is never declared, the JavaScript throws a ReferenceError so Empty(object) isn't true.
isEmpty() Returns true if the collection is empty.
isNotEmpty()

Propagates an assertion using the specified message if the specified object is empty.

Parameters:

  • arg - the object to check.
  • msg - the assertion message.
X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. By continuing to use this site you are giving us your consent to do this.