LogoLogo
API Documentation
Version 1.19.5 and Older
Version 1.19.5 and Older
  • DecisionRules Documentation
  • API
    • API Introduction
    • API Keys
      • Solver API Keys
      • Management API keys
      • BI API keys
    • Rule Solver API
    • Management API
      • Deprecated Endpoints
    • Console Logs API
    • Business Intelligence API
      • Deprecated Endpoints
    • Datacenters & Locations
      • Global Cloud
      • Regional Cloud
    • Apache Kafka Solver API
    • Endpoint Settings
    • Archive
      • Rule Flow Solver API (DEPRECATED)
  • Decision tables
    • Decision Tables Introduction
    • Table Designer
    • Input & Output JSON Model
      • Simple Editor
      • JSON Editor
      • Binding to Model
    • Supported Data Types
    • Operators and Functions
      • Basic operators
      • Date operators
      • Functions
        • Logical Functions
        • Math Functions
        • Date and Time Functions
        • Text Functions
        • Data Functions
        • Array Functions
        • Integration functions
        • Functions and JSON
    • Export & Import of Decision Tables
      • Export Decision Table
      • Import Decision Table
      • File Structure of JSON Format
      • Managing Decision Table in Excel/Google Sheets
      • Deprecated Formats: XLSX v.1 and CSV
    • Table Operations
      • Filter Values
      • Valid Values
      • Sorting
  • Decision Trees
    • Decision Trees Introduction
    • Decision Tree Designer
    • Export & Import Decision Trees
      • Export Decision Tree
      • Import Decision Tree
  • Scripting Rules
    • Scripting Rule Introduction
    • Custom functions in Scripting Rules
    • Calling external API within ScriptingRules
    • Use Rule Variables in Scripting Rules
    • Call Embedded Rules in Scripting Rules
    • Export & Import Scripting Rules
      • Export Scripting Rule
      • Import Scripting Rule
    • Tips
  • Rule Flow
    • Rule Flow Designer
    • Rule Flow Mapping
    • Rule States in Rule Flow
    • Warnings & Errors
    • Rule Flow Limits
    • Export & Import Rule Flows
      • Export Rule Flow
      • Import Rule Flow
  • Workflow
    • Workflow Introduction
    • Workflow Designer
    • Workflow Nodes Overview
    • Workflow Limits
  • Other
    • Rule Alias
    • Execution Strategy
    • Rule State
    • Rule Versioning
    • Favorite Rules
    • Rule Variables
    • Rule Comparison
      • Decision Table Comparison
      • Decision Tree Comparison
      • Scripting Rule Comparison
    • Rule Tags
    • Rule Dependencies
    • Test Bench
    • Single Sign-On (SSO)
    • Event timeline
    • Rule Lock
    • Rule Migration Strategies
    • Changes in Version 1.19.0 (10/2024)
  • Organizations
    • Introduction
      • Access to Organization
    • Structure
      • Organization Roles
      • Members
      • Teams
      • Spaces
      • Space Roles
      • Policies
      • Settings
  • Teamwork
    • Dashboard
    • Folders
    • Spaces
    • Manage Spaces
    • Share Rules Between Spaces
    • Users & Roles
    • Teamwork Indicator
  • SDK and Integrations
    • Languages / Frameworks
      • SQL Server
      • Oracle PL/SQL
      • PostgreSQL
      • JavaScript
      • Java Spring Example
      • PHP Library
      • Python Library
      • .NET Library
      • Google Tag Manager
    • Excel Add-in
  • Business Intelligence
    • Audit Logs
    • Create a Power BI Report
    • Connect Power BI to Business Intelligence API
    • Connecting from Power BI (deprecated)
    • Connect DecisionRules to Power BI Using Our Custom Connector
  • Billing
    • Invoices & Billing
    • Change Product Plan
    • Billing Information
    • Plan Limits Explained
  • Regional Cloud
    • Regional Cloud
    • Region Specific API URLs
  • On-Premise / Docker
    • Environment Variables
    • Redis Connection Modes
    • Setup Single Sign-On (SSO)
      • Set up Microsoft Entra ID SSO
      • Set up Google SSO
    • DecisionRules Application
      • Minimal Requirements
      • DecisionRules Server
      • DecisionRules Client
      • DecisionRules Business Intelligence
      • Networking Between Docker Containers
    • Docker Showcase App
      • Showcase
      • Showcase + Business Intelligence
    • AWS Setup
      • AWS ECS/Fargate
      • Cache - Amazon ElastiCache
    • Microsoft Azure Setup
      • Database - Azure CosmosDB
      • Cache - Azure Cache for Redis
      • Azure Container Apps
    • Azure Red Hat OpenShift
    • Google Kubernetes Engine (GKE)
    • Kubernetes Setup
      • Kubernetes Setup with Business Intelligence
    • Logging options
    • CD/CI Pipelines
      • Azure DevOps CICD Pipelines
      • Using Migration script (old way)
    • Offline License
  • Terms & Conditions
    • Terms and Conditions
    • Privacy Policy
    • Service Level Agreement
      • Community Support
      • Standard Cloud (SaaS)
      • Silver SLA
      • Gold SLA
      • Custom SLA
    • Sub-Processor List
  • Roadmap 🚲 🗺️
  • Release Notes
    • Public Cloud
    • On-Premise / Private Cloud
Powered by GitBook
On this page
  • Categories of Functions
  • General Usage and Principles
  • Syntax
  • Values

Was this helpful?

  1. Decision tables
  2. Operators and Functions

Functions

On this page, you'll get an introduction to the key principles of writing functions in DecisionRules. A detailed guide to all available functions is found in the following sections.

Was this helpful?

DecisionRules functions are essential for building decision processes of any complexity. These functions can be applied in different rule types, such as , and , allowing users to write mathematical and logical expressions in both conditions and results

Categories of Functions

Functions are divided into several categories based on their area of application:

  • Math functions

  • Logical functions

  • Date and time functions

  • Text functions

  • Data functions

  • Array functions

  • Integration functions

General Usage and Principles

Though the functions have broad applications and behaviors, they share several core principles. These apply universally across all functions. Below is a quick overview, supported by basic examples.

Syntax

The syntax for DecisionRules functions is simple. Functions are written using their names (always uppercase, occasionally containing underscores) followed by parentheses that enclose the function arguments, separated by commas.

SUM(1,4,5)  --> 10

Each function accepts a variable number of arguments, some optional, while others do not need any arguments at all.

Example of no-argument function:

NOW()   --> returns the current date and time

In Decision Tables, functions can be used in condition, result, and calculation columns.

  • Condition columns: You can choose the function from the operators modal, which opens when you click the operator badge. Functions in these columns must evaluate to boolean values (true or false).

  • Calculation and result columns: These do not have the operators modal. Simply start typing the function name, and a dropdown whisper will appear, showing all matching functions.

Values

DecisionRules supports several data types:

  • Primitive types: number, string, boolean, null.

  • Complex types: arrays, objects.

  • Additional types for functions: date, regular expressions.

Basic syntax examples:

12.1          --> number
"abc"         --> string
true          --> boolean
false         --> boolean
null          --> null

As shown above, strings are typically enclosed in double quotes. For simple string expressions that do not contain special characters [*/+-(),%{}], the quotes can be omitted. However, we recommend keeping them for clarity and consistency.

Special characters within strings can be handled with either single quotes or escape sequences:

"abcd"        --> abcd
'ab"cd'       --> ab"cd
"ab\"cd"      --> ab"cd
"ab\'cd"      --> ab'cd
"ab'cd"       --> ab'cd
"ab\\cd"      --> ab\cd

Type Conversion

Functions in DecisionRules often handle type casting automatically. If possible, they will convert values to the required type.

SUM(1,4,"5")    --> 10

However, type casting does not always work. If values cannot be converted, the function will either fail validation or return an error at runtime.

SUM(1,4,"abc")    --> invalid

Arrays and Objects

Some functions accept arrays or objects as arguments. DecisionRules uses JSON-like syntax for arrays and objects.

SUM([1,4,5])    --> 10
[1,4,5]                     --> array of numbers
[{"id":"A5B52","price":45}] --> array of objects
{"id":"A5B52","price":45}   --> object with key-value pairs

Nesting Functions

Functions can be nested inside each other. For instance, one function's result can be passed as an argument to another function.

SUM(MAX(1,2),1)    --> 3

Here, MAX(1,2) evaluates to 2, which is then used in the SUM function.

Variables

There are five types of variables that can be used in functions:

  • Input variables: represent the rule's input data.

  • Output variables: represent the rule's output data.

  • Rule variables: user-defined variables with rule-level scope.

  • Calculation column variables: variables declared in calculation columns in Decision Tables.

  • Abstract function variables: special variables used in certain functions.

Variables are referenced using curly brackets ({}).

// number = 3

SUM({number},6)   --> 9

In cases where the value from the variable cannot be used, the evaluation will fail and return an empty value:

// number = "a"

SUM({number},6)   --> null

Functions in Decision Tables

In Decision Tables, functions can be used in condition, result, and calculation columns.

  • Result columns can contain any type of function.

  • Condition columns must evaluate to boolean values (true or false).

  • Calculation columns allow users to define variables or intermediary values that can be used in other columns for more complex calculations.

When using functions in a decision table, you can turn on the Debug Mode and open the Console to see the detail of how they evaluated.

Read more in the section.

Supported Data Types
Decision Tables
Decision Trees
Workflows
How functions can be used in a decision table
Example of functions in the condition and calculation columns