Rule variables
You create a rule variable to define the scope of a rule.
A rule variable is a name to which you assign a value. You define
the variable in the definitions part
of an action rule, and you can use it only in the condition and action
parts of the rule that declares the variable.
Rule variables can make your action rules easier to build and understand by simplifying terms.
Making rules easier to understand
You
might find parts of a rule difficult to understand. For example, the
following rule uses the term of to
chain together business terms:
if the value of the shopping cart of a customer is less than $100 then...
You can shorten this chain of words by using a rule
variable. For example, you can define a variable named the cart to represent the business
terms shopping cart and customer:
definitions set ‘the cart’ to the shopping cart of customer; if the value of ‘the cart’ is less than $100 then...
One rule per rule variable
The scope of a variable is the rule that declares the variable. The name of the variable must be unique in the rule. After you define a variable, it can be used in any part of the rule.
In the following rule,
the definitions part defines
the variable Smith, which
is then used in the if and then parts of the rule.
definitions set Smith to a customer; if the category of Smith is Gold then apply 10 % discount to the shopping cart of Smith;
When rule variables do not match data
A rule can define a rule variable that data cannot satisfy when an application calls the rule.
For example, you might define a variable named 'low risk
borrowers' for all the borrowers whose credit score is at least 200. However, when you run
the rule against data from an application, the rule might not find any borrowers who match the rule
variable. In this case, the rule variable behaves as a condition, and the rule cannot execute the
actions in the then and else parts of the rule.
Restrictions on rule variable names
Do not use the following characters in the names of your variables:
| Character | Description |
|---|---|
| TAB | Tabulation |
| \n | Line break |
| ' | Single quotation mark |
| " | Double quotation mark |
| () | Opening and closing parentheses |
| / | Slash |
| , | Comma |
| ; | Semicolon |
| ’ | Curly quotes |
Single quotation marks
In Intellirule editor, if the name of a rule variable contains one or more spaces, you must enclose the name in single quotation marks when you define or use the variable. If a variable name contains only one word, quotation marks are optional.