Reusable and Inline Rules
A rule can use another rule, so a decision that many rules share is written once and kept in one place. When the shared rule changes and its new version goes live, every rule that uses it follows at once, with nothing to copy or update by hand.
There are two kinds of shared rules:
- A reusable rule is an evaluation rule that other rules use as a condition. For example, a reusable rule "Preferred customer" can be used by any rule as "Preferred customer is True". Whether a rule is reusable is chosen in Is Reusable Rule? when the rule is created.
- An inline rule is an execution rule that other execution rules run as one of their actions, with Execute.... For example, a rule that sends the standard delay notices can be run by every rule that detects a delay. Whether a rule can be run this way is chosen in Can Other Rules Execute It? when the rule is created.
Neither choice can be changed once the rule exists. See Creating Rules.
The components it uses:
- The Rule Editor's menus: reusable rules appear in the menu of fields; inline rules appear under Execute....
- The live versions of the shared rules: a rule that uses another always runs that rule's live version.
- The repository's checks: when you save a rule, make a version live, take one offline or delete one, the repository checks that no rule is left calling something that cannot run.
Using a Reusable Rule in a Condition
- In the Rule Editor, where a condition can start, open the menu of fields.
- Reusable rules are listed in the same menu, by their names. Select one.
- Select is, then Select a value..., then True or False.
The editor offers a reusable rule only when:
- it has a live version,
- it is written against the same source object as your rule, or against the kind of item in one of your source object's lists. A reusable rule written for the items of a list is offered inside a condition on that list, after Collections...,
- it is not the rule you are writing.
Running an Inline Rule from an Execution Rule
- In an execution rule, after then, else if ... then or else, open the menu of actions.
- Select Execute.... The menu lists the rules you can run.
- Select one. The rule reads, for example, "then execute" followed by the rule's name.
The editor offers an inline rule only when it is an execution rule that allows it, it has a live version, it is written against the same source object as your rule, and it is not the rule you are writing.
What Runs When a Rule Uses Another
A rule that uses another rule runs that rule's live version, whatever version was live when the calling rule was written. So:
- Making a new version of a shared rule live changes the result of every rule that uses it, from then on.
- A shared rule's versions that are not live have no effect on the rules that use it.
Before you make a new version of a shared rule live, find the rules that use it and test them. Show related... in the shared rule's dialogs, and Testing Rules, help with this.
What the Repository Refuses
The repository keeps rules that use each other from breaking:
- A rule that uses itself, directly or through other rules, cannot be saved. The editor highlights the element and says "This rule causes or participates in a circular reference".
- A rule that uses a rule that cannot run, for example one with no live version, cannot be saved. The editor says "The rule this element calls could not be found or is not available".
- Making a version live is checked the same way, both ways: the version must not close a circle with the rules it uses, and the rules that already use this rule must still work with it.
- Taking a shared rule's live version offline is refused while the live versions of other rules use it. The confirmation says why and lists those rules as links: take them offline first. To change what a shared rule does, make a new version of it live instead; the new version replaces the old one, and the repository checks that the rules using it still work.
- Deleting a rule that other rules use is refused. See Deleting.