One of the primary constructs in the DropStream rule syntax is when/then
for checking a condition. This construct is represented as an IF-THEN construct in DropStream's GUI Editor and works like a programming language if-then statement that evaluates whether an expression is true, and if it is, does something.
For example, consider the following rule:
when order_item.sku is "My-Order" then add 1.0 item to order_items in order set item.sku to "You-got-a-gift" end end
When an order is processed by DropStream, the rules engine will search for a particular SKU called “My-Order”. If such an item is found, i.e., the condition after when
evaluates to true, the then
block will be executed, and a new order item with an SKU "You-got-a-gift" will be added to the order.
A when/then
construct ends with an end
keyword.
Note: add
statements also include an end
, as illustrated by the following code snippet:
add X item to order_items in order set item.sku to “string” end
Note: A common mistake that can occur while adding an item, is using order_item.sku
or order_items.sku
in the set
command, instead of item.sku
. Here, item
in the add
statement is a variable that is declared in the add
command, so it should be used in the same form after set
, which is "within the scope" of add
.
Comments
Please sign in to leave a comment.