## Tutorial: Rule operations

When you’ve added added elements and conditions to your rule, then you can add operations to manipulate values where needed. Operations can also be used in the actions of a rule. There are two types of operations:

• Unary: operations that take one operand as input.
• Binary: operations that take two operands as input.

Both types of operations have an operator indicating the type of operation that will be performed. Some example operators are:

• Unary: negative value of (number), and not (true/false).
• Binary: (number) plus (number), (text) join (text), (number/text/boolean), and is equal to.

As you can see, binary operations may have the same operators as equation conditions (i.e., is equal to and is not equal to). In fact, an equation is just a binary operation, but an important difference is that equation conditions trigger rule execution, where operations do not. Another similarity between operations and equation conditions are the values that act as the operands (inputs) which can be:

• Constant values: added as elements to a rule.
• Attribute values: belonging to entities or descriptors that are added as elements to a rule.
• Calculated/manipulated values: that are the outcomes of operations added to a rule.

### Example app: Grocery store

In our example app we want to write two different rules:

• Rule 1: Calculate shopping cart total price: when a new product is added to the shopping cart, then the price of the product must be added to the total price of the shopping cart.
• Rule 2: Calculate volume discount: when a customer checks out a shopping cart and the total price of the shopping cart exceeds 100 Euro, then the total amount should be reduced with 10%.

#### Rule 1: Calculate shopping cart total price

To implement rule 1, we need the following operation to calculate the total price of the shopping cart:

• the Amount Shopping cart1 is totalled to plus the Amount Product1 is valued at

#### Rule 2: Calculate volume discount

And the following operation needs to be added to rule 2:

• the Amount Shopping cart1 is totalled to divided by 100 multiplied by 90