Dependency of rule actions on rule variables

You cannot execute the actions of a rule if the rule cannot instantiate its variables.

You define rule variables in the definitions and in the when parts of a rule. A rule cannot perform the actions, if it cannot instantiate its variables, that is, if the variables do not match existing data.

If a rule has variables and conditions, the rule can apply its else part only if the variables can be instantiated and the conditions are not true.

The following rule always applies a discount because every customer receives a discount of at least 5 percent:

if 
    all of the following conditions are true:
        - the value of the shopping cart of 'the customer' is more than 100 
        - the category of 'the customer' is Gold 
then 
    print "apply a 15% discount"; 
else 
    print "apply a 5% discount"; 

However, you can change the rule by using the definitions part to give a discount only to customers in the Gold category:

when a purchase event occurs
definitions 
    set 'the customer' to the customer of this purchase event
        where the category of this customer is Gold; 
if 
    the value of the shopping cart of 'the customer' is more than 100 
then 
    print "apply a 15% discount"; 
else 
    print "apply a 5% discount"; 

You can also change the rule by using the when clause to give a discount only to customers who have bought for an amount of over 200.

when a purchase event occurs 
    where the amount of this purchase event is more than 200
if the category of 'the customer' is Gold
then 
    print "apply a 15% discount"; 
else 
    print "apply a 5% discount";