A rule could have multiple rule sets. To check multiple cases to execute an action, create forward cases for each condition and set the execute action at the end.

The result of a rule expression should always be a Boolean value.  The following sections provide the list of operators supported for writing Rule Expressions.

Arithmetic Operators:

The following arithmetic operators are supported and designated in the order of precedence.

( )

* /

+ -

Parentheses (): Used to designate which part of the expression should be evaluated first.

For example: in the following example, the sum of transaction value and the discount is calculated first and then the result is multiplied by 40 (as these are in parenthesis).  Then the entire value is divided by 100.  

currentTxn.discount<=(((currentTxn.value+currentTxn.discount)*40)/100)

 Note: The expression is always evaluated from left to right.

Mod Operator (%)


Use the expression to check if a value of an expression is divisible by a specific number. You can define rules based on the reminder of the modular expression.

The following expression says, check if the remainder of the transaction value divided by 100, is less than 10. 

currentTxn.value%100<10


Equal to, Not Equal to, Greater than, and Less than

The following example demonstrates how to write expressions with equal to, not equal to, greater than, and less than operators:
Equal to:

An expression to check customers is in the loyalty tier number 3.  

currentCustomer.slabNumber==3

  

Not Equal to:

An expression to check customers who are not in the tier named 'Normal'. 

currentCustomer.slabName!="Normal"

 

Greater than

An expression to check customers who are not in the base tier.  

currentCustomer.slabNumber>1

  

Less than

 An expression to check if the value of the current tracker is less than the specified value.

 currentTrackerCondition.trackerCurrAggr<12000


And/or Operators:

Use 'and'(&&) operator to check multiple expressions at a time. 
(currentCustomer.slabNumber>currentCustomer.initialSlabNumber)&&(currentCustomer.slabNumber==3)

 

Use 'or' (||) operator to execute the action if any of the expressions mentioned is successful. The following example says, check customers who have either paid through cash or cash.
tenderProfile.code=="CASH"||tenderProfile.code=="CARD"

 

Date Formats

The following sample expressions shows how to use date attribute in different scenarios    

<!--Standard Format -->
currentTxn.date.isAfter(YYYY,MM,DD,HH,MM,SS)&&currentTxn.date.isHourBetween(HH,HH)&&currentTxn.date.isTimeBetween(HH,MM,HH,MM)

<!-- Example to check date and time intervals -->
currentTxn.date.isAfter(2015,04,25,00,00,00)&&currentTxn.date.isHourBetween(10,12)&&currentTxn.date.isTimeBetween(10,20,11,30)

<!-- Example to check duration -->
currentCustomer.joinDate.daysDiff(currentTxn.date)>=10

<!-- Example for using date difference -->
currentTxn.date.dateDiff(currentCustomer.joinDate)>2

<!-- Example for using date difference from string -->
currentTxn.date.daysDiffFromString("2015-02-14T00:00:00.0000000UTC+05:30")<104

<!-- Example for using transaction between -->
currentTxn.date.isHourBetween(17,20)

<!-- Example for using time between -->
currentTxn.date.isTimeBetween(10,20,11,30)

<!-- Example for using date is after -->
currentTxn.date.isAfter(2015,06,14,13,11,33)

<!-- Other examples -->
currentCustomer.joinDate.day("2")
currentCustomer.joinDate.dayOfMonth("25")
currentCustomer.joinDate.isValid("anyString")
currentCustomer.joinDate.isWeekday("ANYSTRING")
currentCustomer.joinDate.isWeekend("ANYSTRING")
currentCustomer.joinDate.month("11")
currentCustomer.joinDate.year("2016")

<!-- An example of using multiple scenarios in a single rule expression -->
currentTxn.date.isAfter(2015,04,25,00,00,00)&&currentTxn.date.isHourBetween(10,12)&&currentTxn.date.isTimeBetween(10,20,11,30)