tricksadvanced
Call Rule From Script
This example shows how to simply call any rule from a Scripting Rule, which might be useful e.g. when building a complex orchestration.
Leos Rehacek
Template author
This Decision Flow demonstrates the capability to invoke a specific rule from within a Scripting Rule programmatically. Instead of a Decision Flow, this orchestration uses a script to pass input data to a child rule (a Decision Table) and retrieve the results for further processing or output. This pattern is useful for building complex orchestrations where rule execution may depend on logic defined in JavaScript.
Solution components
The solution consists of two primary rules contained within the "Call Rule From Script" folder:
- Child Table: A Decision Table that functions as a lookup engine, assigning product details based on a category code. This table defines the business logic for mapping category codes to specific banking products. It evaluates the Code (mapped from categoryCode) to determine the Product Name and Product Code.
- Input: The table accepts a Code (e.g., "OA" or "SA").
- Logic:
- If the Code is OA, it returns "Regular Account" (OAO1).
- If the Code is SA, it can return "Saving Account Standard" (SAO1) or "Saving Account Premium" (SAO2).
- Output: It returns the productName and productCode.
- Call Rule From Script: A Scripting Rule that acts as the orchestrator. It accepts input, calls the decision table using its unique alias, and outputs the matched rows. It does not contain a decision table itself but uses JavaScript to leverage the Decision Rules engine (DR).
- Logic:
- It utilizes the DR.solve function to target the child rule by its alias.
- It passes the input variable categoryCode to the child rule.
- It uses a standard solver strategy (SolverStrategy.STANDARD).
- Result: The script logs the result and maps the output of the Decision Table (tableResult) to the script's output variable matchedRows.
More Templates
See Other Templates
financial servicessuggested
A/B Testing
Discover a simple way to assign a test group for performing A/B Testing on your decisions.
financial servicessuggested
Risk Based Pricing
Discover a simple way to apply a suitable Risk Based Pricing matrix based on a type of client.
financial servicessuggested
Eligibility and Policy Rules
Discover a simple way to define and execute various sets of rules and get the final decision outcome.