Working with business rule variables
It is possible to define a variable in PolicyCenter business rules that stores a specific expression or value for later reuse in the rule. In this manner, you define an expression once and then reuse it at will in the conditions or actions of the rule. Thus, rule variables are similar to rule symbols. Just as you can use symbols defined in the context definition in the rule conditions and actions, you can use variables in the rule conditions and actions as well.
Adding a rule variable
Guidewire recommends that you first set the rule context before defining the rule variable (as you must with condition expressions as well). This ensures that the rule editor recognizes any rule symbol that you use in the variable expression.
To add a rule variable to a rule, place the rule in edit mode and click Add in the Variables section of the editor. It is possible to add multiple variable rows in the Rule Variables section by clicking Add multiple times. However, if you do so, PolicyCenter removes any variable row that is completely empty during a save operation of the rule edits.
| Field | Required | Description |
|---|---|---|
| Name | Yes | Use alpha-numeric characters only. The variable name must start with a letter and meet Java naming conventions. The variable name cannot be a reserved Gosu or Java keyword. Each variable name must be unique within the entire variable name space. |
| Description | No | A simple sentence that describes the meaning and purpose of the variable. |
| Expression | Yes | Expressions that you enter in this field must one of the following forms:
|
| Type | PolicyCenter populates this read-only field automatically after you enter a value in the Expression field. This field shows the return type of the defined expression. |
After you define the rule variable values, and after PolicyCenter determines the variable name and expression to be valid, PolicyCenter adds the rule variable to the rule context definition.
Each rule variable that you define must have a unique name across the entire variable name space. However, a variable that you define in a rule is only available to that rule, not across other rules. A variable that you define in a particular rule version is not available to prior versions of that rule. Thus, rule versioning, rule lifecycle, rule deployment, and rule import and export all apply to rule variables as well.
Working with rule variables
Rule variables work in exactly the same manner as the other symbols in the context definition. This means that you can perform such operations as var1 + var2 and other similar operations.
- It is possible to use variable expressions of any form in rule condition and action statements, on either side of the line.
- It is possible to use rule variables in underwriting rule action
parameters that permit Gosu expressions. Use the
${}construct to enter a variable into an action parameter. - It is not possible to nest one variable inside another variable. (A variable expression cannot itself contain a previously defined variable.) However, it is possible to use variables in any of the nested expressions (sum, count, lookup) if accessed through the condition builder.
- It is not possible to use rule variables whose form is Sum or Count within underwriting rule action statements.
PolicyCenter invalidates the entire rule if a rule variable is invalid.
Removing a rule variable
If you use a variable in a condition line and then delete the variable definition, PolicyCenter generates a validation error. If you rename a variable, PolicyCenter again generates a validation error if the variable exists in a rule condition line.
Lookup expressions and rule import
During rule import, if a rule has a lookup expression defined to a lookup table that does not exist in the target environment, PolicyCenter marks the rule as invalid. The import of the rule still succeeds. However, you must make the necessary changes indicated in the Rule Detail screen to make the rule valid before it can execute in the target environment.
