Expression Rule Examples

The following are examples of expression rule fields, functions, and samples of expression rules.

An expression rule can rank or exclude a particular fulfillment site by looking at site, trial shipping order information as well as site-level order and order item attributes. It also can be used in a combination of both site and trial shipping order. For site-level attributes, each order item is run (iterates) one order-level item at a time. The Utilities library ($utils) enables you to execute a predefined function when evaluating an expression.

1 #set($rank = 10) 
2 #if($site.Type == "Store") 
3    #set($rank = $site.Attributes.test) 
4 #end 
5 $rank

Exclude a Site

To exclude a site, the expression returns the word EXCLUDE (not case-sensitive). The following expression excludes the site type of 'store'.
1 set($exclude = "") 
2 #if($site.Type == "Store") 
3   #set($exclude = "EXCLUDE") 
4 #end 
5 $exclude

Rank a Site

To rank a fulfillment site, the expression returns a value between 1 and 1000, where 1 is the lowest rank or non-preferred site and 1000 is the maximum rank or preferred site. The following expression rank is based on the site type.
1 #set($rank = 1) 
2 #if($site.Type == "Warehouse") 
3   #set($rank = 1000) 
4 #end 
5 $rank

Included Fields

Iterations

When evaluating order items, each order item is run (iterated) one order item at a time.
1 #set($exclude = "")
2 #foreach($row in $order.OrderItems)
3 #if($row.Attributes.Exclude == "EXCLUDE")
4      #set($exclude = "EXCLUDE")
5 #end
6 #end
7 $exclude

Utilities Library

The Utilities library ($utils) enables you to execute a predefined function when evaluating an expression. They include the following:

Examples

X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used. By continuing to use this site you are giving us your consent to do this. Privacy Policy.