Rule Variables

Rule variables simplify editing when working with values that appear multiple times across your rules.

Rule variables work identically across all rule types - Decision Tables, Decision Trees, and Scripting Rules - though the syntax for using them varies by rule type.

circle-info

Rule variables are version-specific. Each version of a rule maintains its own set of variables.

circle-info

In this guideline on how to create rule variables, you need to have knowledge of Decision Table and Scripting Rule

Creating and Managing Rule Variables

Rule Variables are managed in the left panel of the rule editor. Here you can add, edit, or delete variables.

To create a new variable:

  1. Enter a Name (must be unique per rule).

  2. Set a Value (number, text, or boolean).

  3. Click the Save button or click Enter.

circle-check

To edit a variable:

  1. Click the Edit button next to the variable.

  2. Modify the value.

  3. Click the Save button or click Enter.

circle-exclamation

To delete a variable:

Click the Delete button next to the variable.

Supported Value Types

Rule Variables support the following data types:

Simple Values

Arrays

JSON Objects

circle-exclamation

What Rule Variables CANNOT Do

Rule variables have important limitations that you should understand:

Reference other values

Rule variables are static values only. You cannot reference one variable from another or perform calculations between them.

While you might think {input.field} syntax would work based on other features, rule variables do NOT support input placeholders. The curly braces are treated as literal text.

Execute functions

Functions stored in rule variables are NOT executed - they are returned as strings.

circle-info

If you need to use functions, write them directly in table.

How to use Rule Variables

Rule Variables in Decision Tables

There are several ways to use Rule Variables in Decision Table Designer:

As the Column Condition

In the column header, you can use the variable name directly.

As the Comparison Value

In the condition cell, you will see reference with the A prefix

Both approaches achieve the same result - comparing input data against your rule variable. Choose the style that makes your table more readable.

circle-exclamation

As Part of the Function

Rule variables can be used inside functions and mathematical expressions, just like any other value (input fields, column values, or static numbers).

This is useful when you want to calculate output without hardcoding them in each cell. If value change, you only update the variable once.

circle-info

Exactly the same use of Rule Variable applies to Decision Tree.

Rule Variables in Scripting Rule

Usage of Rule Variables in Scripting Rules is super easy. All values are stored in the ruleVariables object that is exposed in the script. You can use these stored values everywhere in the script (as inputs for your function or as inputs for DR.solve() function).

You can access your Rule Variables with the dot notation same as with input and output. To get the value of a rule variable, you write ruleVariables.<nameOfYourRuleVariable>

triangle-exclamation

Last updated

Was this helpful?