Try OpenEdge Now
skip to main content
BPM Events User's Guide
The rule language : Controlling the actions of a rule : Conditional action statements
 

Conditional action statements

Conditional action statements can execute different actions based on some condition. Note that the condition here is not the same as the rule condition (if clause of the rule); but is a condition used inside the Action part of the rules, which means it is checked only when the rule is successfully triggered.
The general syntax for a conditional statement is:
<ConditionalStatement> ::=
"if" <condition> ")" <ActionStatement> [ "else" <ActionStatement> ]
Note: The else part is optional. The condition follows exactly the same syntax as for the main condition part of the rule.
In the following example of this rule, a sequence of three action statements exists in the Action part.
rule earlybird_discount
activated by evt1 of BP Server::PI_ACTIVATED{PROCESSTEMPLATENAME : "CustomerRequest"}
then {
    if ( (evt1.totalamount >= 500)
        and (evt1.reqtype = "ProductOrder")
        and (ReqStats["ProductOrder"][ evt1.region].count < 1001))
        ReqStats["ProductOrder"][ evt1.region].count += 1;
    ReqStats["ProductOrder"][ evt1.region].totalamount += evt1.amount;
}
The second one is the conditional statement, which uses a complex condition. It has a functional statement ReqStats["ProductOrder"][ evt1.region].count += 1;
It does not have an else part. The statement:
ReqStats["ProductOrder"][ evt1.region].totalamount += evt1.amount;
is the next statement after the conditional statement.