Action rules

You express business policies in rules that match actions to conditions.

An action rule defines the specific actions to take when certain conditions are met. A basic action rule uses an if-then statement to associate a condition (if) with an action (then). The rule states what action to perform when a condition is true, for example:

if
	the credit score of ‘the borrower’ is less than 200
then
	in 'the loan report', reject the loan with the message "Credit score too low.";

You write an action rule as a sentence in a natural language. The rule is composed of business terms, operators, and values. In the example, the credit score of the borrower is a business term, is less than is an arithmetic operator, and 200 is a value.

Business applications call the rules to execute them, and provide data values for the business terms. In the example, the action rule must access data for the business terms the credit score of the borrower and the loan report.

To provide a complete statement, an action rule can consist of four parts: definitions, if, then, and else.

The following example shows the four parts in a rule:

definitions 
	set applicant to a customer 
		where the category of this customer is Gold 
if 
	the value of the applicant's shopping cart is more than $100 
then 
	apply a 15% discount 
else 
	apply a 5% discount
Definitions (definitions)
Use the definitions part to define variables for the rule.

The definitions part is optional.

Conditions (if)
Use the if part to specify the conditions for performing the actions in the then and else parts. In the example, the condition is the value of the applicant's shopping cart is more than $100.

The if part is optional. Rules without conditions perform their actions under all circumstances.

Actions (then)
Use the then part to define one or more actions to perform if the if part is true. The action in the example says to apply a 15% discount if the if part is true.

The then part is mandatory. The rule must have at least one action.

Alternative actions (else)
Use the else part to define one or more actions to perform if the if part is false. The else part of the example says to apply a 5% discount if the if part is false.

The else part is optional. If the if part of a rule is false, and there is no else part, the rule does not execute an action.