Reference > Rule Languages > Business Action Language > BAL Constructs > definitions

Summary

Introduces the part of the rule that lets you define variables.

Syntax

definitions
    set <variable> to <definition> [in <list> / from <object>] [where <test>*] ;*

Description

Variables allow you to write more concise rules by using a short, convenient identifier to represent a value or the result of an expression.

Variables defined in the definitions part of a rule are local to the rule in which they are defined. A local variable can be used anywhere within this same rule, but is not available in other rules. You define local variables using the set <variable> to <definition> construct.

You can also define global input/output variables (called ruleset parameters) at the application or rule project level. Ruleset parameters are accessible to any of the rules in your project. Ruleset parameters are created and edited in Rule Studio.

Example

The following example declares the local variable `preferred customer' in the definitions part of the rule and uses it in the if and then parts of the rule.

definitions 
   set 'preferred customer' to a customer;
if 
   the age of 'preferred customer' is less than 18
then 
   apply a 10% discount to the shopping cart of 'preferred customer';

Related Concepts

Rule Definitions

Related Tasks

Creating Business Rules

Related Reference

from <object>
in <list>
set <variable> to <definition>
the number of <objects>
where <test>

Related Samples and Tutorials

Tutorial: Creating Business Rules