Tutorial: Rule elements

The first step in writing a rule is selecting which elements play a role in the when part, being the conditions that trigger the execution. The two types of elements that can be added to the conditions of a rule are:

  • Entity instance: an instance of an entity type as defined in the nouns section of your app.
  • Constant value: a value of type text, number or boolean (true or false).

A rule may contain more than one instance of the same type. Therefore, both entity and descriptor instances are written with an instance number. Constant values are written in bold orange.

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

For rule 1 we need to add two elements:

  • Shopping cart1
  • Grocery product1

Rule 2: Calculate volume discount

And for rule 2 we need we must add two elements:

  • Customer1
  • Shopping cart1

And we must add the constant values:

  • 90
  • 100