Variables available for rule authoring
A variable comprises three elements:
-
Name
-
Type
-
Value
You define variables so that you can use the name independently of the value it represents. Variables can make your business rules less ambiguous and easier to understand.
A variable name must not contain any of the following characters:
| Character type | Example |
|---|---|
| Tabulation | TAB |
| Line break | \n |
| Single quotation mark | ‘ |
| Double quotation mark | “ |
| Opening and closing parentheses | () |
| Slash | / |
| Comma | , |
| Semicolon | ; |
A variable can have one of the following value types:
| Variable value type | Example |
|---|---|
| Constant |
|
| Expression |
|
| Object | For example, a reference to a predefined business term: the customer |
| Collection of values of the types already listed | For example, a list of numbers {
1, 3, 5 }, a list of objects {
CHINA, FRANCE, UK, USA } |
The following tables list the different types of variables that you can use in your business rules.
An automatic or implicit variable has a predefined name and type, and is set automatically or implicitly by the system:
| Variable | Scope | Definition and use |
|---|---|---|
| Automatic variable | A variable that is available in all the business rules that use the BOM class where the variable is declared. | |
| Implicit variable | A variable that is automatically declared by a language construct like a binding. For example: |
Built into the Business Action Language. The name, type and value are controlled by the system. You use implicit variables to refer to a current instance of an object that is being tested or declared, or to a collection that is being iterated. Implicit variables are visible only in the code completion menu of the Intellirule editor. |
You can define your own rule variables, ruleset variables, and ruleset parameters:
| Variable | Scope | Definition and use |
|---|---|---|
| Rule variable | A variable that can be referenced only in the action rule in which it is defined. |
You define a rule variable in the definitions part of the rule. Rule variables are local to the rule in which they are defined. They are not available in other rules. The variable name must be unique within the rule. |
| Ruleset variable |
A variable that can be referenced by all the business rules in a rule project. Ruleset variables are not available outside of the rule project scope. |
You define a ruleset variable in a variable set in the rule project. Before you define a ruleset variable therefore, you must create a variable set in which to group your ruleset variables. You define a ruleset variable by its name, type, and verbalization. Ruleset variables are accessible from business rules only if you verbalize them, that is, if you specify the text to be displayed in the rule editors. Make sure that you set default values to ruleset variables before you use them in rules. You can also use ruleset variables to pass data between tasks in a ruleflow. |
| Ruleset parameter |
A ruleset parameter is a variable that is defined as the interface between the calling application of a ruleset and the ruleset itself. It has a direction: in, out, or in-out. The direction indicates whether the caller passes data in, expects data out of the ruleset, or passes data in and expects some modifications to the data passed in. |
You define a ruleset parameter in the signature of a decision operation in a decision service. You use ruleset parameters to exchange data between a ruleset and an application, and as the main data elements on which the rule operates. Ruleset variables are accessible from business rules only if you verbalize them, that is, if you specify the text to be displayed in the rule editors. |