Setting up automatic variables

You set up automatic variables to define a variable that can be accessed anywhere in business rules.

About this task

To define a variable that can be accessed anywhere in business rules, you can set up automatic variables. Automatic variables are bound to the instance of the class on which it is defined. Automatic variables are variables that you declare as an instance of a specific BOM class. They are available in all the business rules that use the BOM class where the variable was declared.

When you specify an automatic variable, it is defined for the corresponding business term, and identified with the article “the”. For example, if customer is a business term, a corresponding variable called the customer is available in the rule editors.

Note: This is valid only for the locales that use this type of article.

You cannot define one variable to be the same as another variable of the same type. If your rule requires you to refer to more than one occurrence of customer, you have to define the other variables explicitly, in the definitions part of the rule. In this case, the automatic variable will no longer be available in this rule.

The automatic variable is known internally as customer. The variable the customer is the automatic variable in a given verbalization context (with definite article the) and is the form that you can use in rules to reference this variable. Consequently, you cannot declare another variable named customer in the definition part of a rule:

definitions  set 'customer' to a customer;

This statement will generate the error:

"An automatic variable 'customer' is already declared"

For example, in the following rule, ceiling is an explicit variable declared in the definitions part of the rule, and the customer is an automatic variable.

definitions  set ceiling to 10,000;
if  the value of the shopping cart of the customer is more than ceiling
then...

You cannot declare a ruleset parameter or variable with the same name as an automatic variable. If you do, Rule Designer redirects references to automatic variables such as the customer to the ruleset parameter. For example, if the rule project contains a ruleset parameter called customer, in the following condition, the customer references the ruleset parameter instead of the automatic variable:

if
   the salary of the customer is more than 100 ...

Procedure

To generate an automatic variable for a business class:

  1. In the Outline view, click the class for which you want to generate an automatic variable.
  2. In the Class Verbalization section of the BOM Editor, select the Generate automatic variable box.
  3. Save the BOM.

    An instance of the class is now available as an automatic variable from business rules.