Variables in Business Rules

A variable is a temporary data item that is assigned a default value at the start of rules processing. The variable can be modified by rule actions during processing.

Other rules can then use it as a condition for triggering certain actions based on its value. The value of the variable isn’t stored in the database, so it returns to its default value the next time the rules engine begins processing.

Note: You can use a custom field to accomplish the same function as a variable. If you’re deciding whether to use a custom field or a variable, ask yourself whether you need the data for future reference. A variable is temporary, so it returns to the initial value each time the rules engine is run. A custom field, however, is fixed. At the end of rules processing, it stores the final value in the database. This is available at the start of the next round of rules processing for the object.

Rule variables are useful when you want to accumulate a value and save it conditionally or perform some action based on the accumulated value. A common example of a variable is a score. You can modify a variable based on whether the evaluated object matches rule conditions. Then you can assign different actions based on the variable’s value. For an example of a rule using a variable, see Create a Variable to Measure Service Quality.

See Add or Edit a Variable for the procedure to add or edit a variable.

Rule Actions for Variables

Variable Data Type Actions
Integer
  • Set equal to an absolute value.
  • Increment by n.
  • Decrement by n.
  • Set equal to the value of another integer variable or custom field.
Text Field
  • Set equal to an absolute string.
  • Prefix character string.
  • Append character string.
  • Set equal to the value of another character variable or custom field.

See Actions to Set Custom Fields and Variables for information about how leading and trailing spaces are handled when rule actions are used to set variables.

Date Field
  • Set equal to an absolute value.
  • Increment by n days.
  • Decrement by n days.
  • Set equal to the value of another date variable or custom field or object date or date/time field.
Date/Time
  • Set equal to an absolute value.
  • Increment by n days, hours, or minutes.
  • Decrement by n days, hours, or minutes.
  • Set equal to the value of another date/time variable or custom field or object date or date/time field.