LogoLogo
API Documentation
Current Version
Current Version
  • DecisionRules Documentation
  • DecisionRules Academy
  • API
    • API Introduction
    • API Keys
      • Solver API Keys
      • Management API keys
      • BI API keys
    • Rule Solver API
    • Management API
      • Rule Migration Strategies
      • 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)
  • AI Assistant
    • About Assistant
    • Assistant Setup
      • Gemini Assistant
  • RULES
    • Rules Introduction
    • Rule List
    • Rule Mode
    • Common Rule Features
      • Input & Output Model
        • Simple Editor
        • JSON Editor
      • Test Bench
      • Rule Alias
      • Rule State
      • Versioning
      • Rule Variables
      • Execution Strategy
      • Rule Dependencies
      • Rule Export & Import
        • Rule Export
        • Rule Import
        • Managing Decision Table in Excel/Google Sheets
        • Deprecated Formats: XLSX v.1 and CSV
      • Tags
      • Rule Comparison
        • Decision Table Comparison
        • Decision Tree Comparison
        • Scripting Rule Comparison
      • Rule Lock
      • Teamwork Indicator
      • Event Timeline
    • Data Types & Functions
      • 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
    • Decision Table
      • Table Designer
        • Table Operations
          • Filter Values
          • Valid Values
          • Sorting
      • Binding to Model
    • Decision Tree
      • Tree Designer
    • Workflow
      • Workflow Designer
      • Workflow Nodes Overview
      • Workflow Limits
    • Scripting Rule
      • Custom functions in Scripting Rules
      • Calling external API within ScriptingRules
      • Use Rule Variables in Scripting Rules
      • Call Embedded Rules in Scripting Rules
      • Tips
    • Rule Flow
      • Rule Flow Designer
      • Rule Flow Mapping
      • Rule States in Rule Flow
      • Warnings & Errors
      • Rule Flow Limits
  • SPACE
    • Space Introduction
    • Space Info
    • Dashboard
    • Access
    • API Keys
    • Audit Logs
  • Organization
    • Organization Introduction
    • Organization List
    • Members
    • Teams
    • Spaces
    • Space Roles
    • Policies
    • Statistics
    • Settings
  • Profile
    • Profile Introduction
    • General
    • Dashboard
    • Plans
    • Add-ons
    • Limits
      • Plan Limits Explained
    • Subscriptions
    • Invoices
  • Access
    • Sign Up & Login
    • Invitations & Permissions
    • Single Sign-On (SSO)
  • Business Intelligence
    • Audit Logs
    • Power BI Connectivity
      • 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
  • OTHER DEPLOYMENT OPTIONS
    • Regional Cloud
      • Region Specific API URLs
    • Docker & On-Premise
      • Environment Variables
      • Redis Connection Modes
      • DecisionRules Application
        • Minimal Requirements
        • DecisionRules Server
        • DecisionRules Client
        • DecisionRules Business Intelligence
        • Networking Between Docker Containers
      • Setup Single Sign-On (SSO)
        • Set up Microsoft Entra ID SSO
        • Set up Google SSO
      • 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
      • White Labeling
  • 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
  • Terms & Conditions
    • Terms and Conditions
    • Privacy Policy
    • Service Level Agreement
      • Community Support
      • Standard Cloud (SaaS)
      • Silver SLA
      • Gold SLA
      • Custom SLA
    • Sub-Processor List
  • Product Updates
    • Release Notes
      • Public Cloud
      • On-Premise / Private Cloud
    • Major Updates
      • Changes in Version 1.19.0 (10/2024)
      • Changes in Version 1.20.0 (4/2025)
    • Roadmap
Powered by GitBook
On this page
  • How to call embedded rules
  • Parameters
  • Return type
  • Examples
  • Example of usage
  • Decision table 1: "0000-0000-0000-0000"
  • Decision table 2: "1111-1111-1111-1111"
  • Scripting Rule

Was this helpful?

  1. RULES
  2. Scripting Rule

Call Embedded Rules in Scripting Rules

You can simply run solver of another rules directly from Scripting Rule.

How to call embedded rules

You can run solver of other rules from Scripting Rule.

Solver is available under class DR and method solve().

DR.solve(ruleId, data, version, SolverStrategy)

Everything that you need is the rule ID and solver input data. Optionally, you may specify the version of the called rule and the execution strategy.

Note that you can use rule alias instead of rule ID to identify the rule. In that case, make sure that the rule alias is unique within the space, otherwise the request will fail.

If you are importing/exporting existing rules, DO NOT forget to change the ruleID you are calling in the scripting rule!

Parameters

name
type
mandatory
description

ruleId

string

Id of solving rule. You can also use rule alias.

data

any

Input data for solver

version

number

Version of solving rule

SolverStrategy

Solver strategy of solver

Return type

DR.solve() is returning the response from Solver as Array.

Examples

Basic method

DR.solve("ruleId", data);

Method with rule version

DR.solve("ruleId", data, 5);

Method with Solver Strategy

DR.solve("ruleId", data, 5, SolverStrategy.FIRST_MATCH);

Example of usage

Decision table 1: "0000-0000-0000-0000"

Input Model

{
  "age": {}
}

Output Model

{
  "result": {}
}

Table

Decision table 2: "1111-1111-1111-1111"

Input Model

{
  "total amount": {},
  "blocked": {}
}

Output Model

{
  "result": {}
}

Table

Scripting Rule

Script

// Get data from Input
const data = input.data;

// Check if data is in Input and if data is an Array
if(data && Array.isArray(data)){

    const dates = [];

    // Iterate over data array
    for(let dat of data){
        // Check if dat (member of data array) has parameter date;
        if(dat.date){
            // add date to dates
            dates.push(dat.date);
        }
    }

    // Create BULK input data for DT
    const DTdata = [];

    for(let date of dates){
        const input = {
            "age": date
        }
        DTdata.push(input);
    }

    // log input data for DT
    log(JSON.stringify(DTdata));

    // Call first DT with FIRST_MATCH strategy
    const DTresult = DR.solve("0000-0000-0000-0000", DTdata, 1, SolverStrategy.FIRST_MATCH);

    // log result from DT
    log(JSON.stringify(DTresult));

    // transform data from DT to another DT
    let blocked = 0;

    for(let res of DTresult){
        if(Array.isArray(res)){
            if(res[0].result && res[0].result == "BLOCKED"){
                blocked ++;
            }
        }
    }

    // Create input data for DT
    const DTdata2 = {
        "total amount": dates.length,
        "blocked": blocked
    }

    // log input data for DT
    log(JSON.stringify(DTdata2));

    // Call second DT with FIRST_MATCH strategy
    const DTresult2 = DR.solve("1111-1111-1111-1111", DTdata2, 1, SolverStrategy.FIRST_MATCH);

    // log result from DT
    log(JSON.stringify(DTresult2));

    // pass result from DT to SR result
    output.result = DTresult2[0].result;

}

return output;

Input

{
	"data": [
		{
			"date": "01/01/1990"
		},
		{
			"date": "01/01/1999"
		},
		{
			"date": "01/01/1930"
		}
	]
}

Output

[
  {
    "output": "PASS"
  }
]

Last updated 7 months ago

Was this helpful?

If you want to define you have to specify the rule version too.

The rules you want to call in the scripting rules must be in the same .

Solver Execution Strategy
space
Execution Strategy