The <rule> element invokes a business rule from a business process. When a <rule> executes, it invokes its associated business rule (named by the rule attribute) and gets its response immediately (in the same manner as a <code> or <assign> activity).
Identifying the Rule
When you use the <rule> element in BPL, the value of the rule attribute can be either of the following:
If any <rule> element identifies a simple Rule Name, InterSystems IRIS automatically prepends a Package Name that is equal to the full package and class name of the BPL business process that contains that <rule> element. That is:
This combination must identify a valid rule within the namespace, or the return value of the <rule> will be a null string.
Identifying the Context
By default, the ruleContext passed to the rule is the business process execution context. If you specify a different object as a context, there are some restrictions on this object: It must have a property called %Process of type Ens.BusinessProcessOpens in a new tab; this is used to pass the business process calling context to the rules engine. You do not need to set the value of this property, but it must be present. Also, the object must match what is expected by the rule itself. No checking is done to ensure this; it is up to the developer to set this up correctly.
A Simple Example
The following is a BPL excerpt showing the use of the <rule> activity with a <switch> element to process the results from the rule:
<!-- ...Rule is true... -->
<!-- ... Rule is false... -->
The <rule> activity in this example returns a Boolean value (true or false) according to InterSystems IRIS conventions. That is, an integer value of 1 means true; 0 means false. All rules return a single value, as in this example, but the type need not be Boolean. The single value returned from a rule may be any literal value such as an integer number, decimal number, or text string.