- 27 Jun 2024
- 3 Minutes to read
- Print
- DarkLight
Creating a Rule Chain
- Updated on 27 Jun 2024
- 3 Minutes to read
- Print
- DarkLight
Overview
Rule Chains are a set of Rules combined together in sequence, where every Rule produces a fact that is both an Output of and can be consumed in Rules further down the Chain. Rule Chains can be set up using more than one method. Deciding on the method that will be used is completely up to the preference of the Designer.
Why Rule Chains are Used
Rule Chains can be used to build dynamic questionnaires, where Chained Rules govern if a follow-up question is asked or not. Rule Chains can be used to help evaluate a specific rate or qualify a lead, diagnose a patient, approve an application, or generate an output for wherever business processes require dynamic decision making.
Steps for a Rule Chain Flow
When building a Rule Chain Flow, there will be a limited Toolbox of steps to use:
- Business Knowledge
- Debugger Rule Results
- Input Data
- Knowledge Source
- Matrix Rule
- Should Continue [Flow Control]
- Statement Rule
- True-False Rule [Flow Control]
- Truth Table
Defining Data for the Rule Chain
Before a Rule Chain can be created, it needs Data to evaluate. There are two ways to get outside Data into the Rule Chain:
- Define Inputs to be mapped into the Rule Chain
- Define Constant Data that will only be used within the Rule Chain.
Data Specific steps
Input Data
Input Data steps allow for the custom definition of the Data Members needed as Inputs for the Rules in the Chain. Input Data steps can also have unlimited paths coming in and out of them.
No Supplied Input Data
Two things happen when Data is not supplied to an Input.
- All steps connected to a Null Input Data step do not execute. Input Data steps create a dependency on all connected steps.
- The Rule Chain itself outputs a list of Inputs without Data Supply as DataDescription[]. This list can be used outside of the Rule Chain to determine why certain facts were not produced by the Rule Chain.
Business Knowledge and Knowledge Source
These steps allow for the creation of Constant data within the Rule Chain. The declared Data is passed into all connected steps as available input data. No mapping outside of the Rule Chain is required.
Adding Rules to a Rule Chain
Decisions Rule Steps
By design, Data is automatically mapped into connected Rule steps. To use Rule steps in a Rule Chain:
- From the Rule Chain Designer, add the desired Rule step from Toolbox > RULE CHAINING [DMN] to the workspace.
- Drag out one of the connection points from the Input Data to the Rule step.
- Select the Rule step then click the EDIT button.
- Define the Rule as usual by utilizing the connected Input Data as the Rule Inputs.
Outputting Data within the Rule Chain
To change this behavior, in the Rule Chain Designer, toggle Continue Execution With No Rule Result.
Outputting Data within the Flow
When the Rule Chain is called in a Flow as a step, the result data of the rules are Output by the entire Rule Chain step. These are referred to as the Facts that the Rule Chain step is able to produce.
Forward Chaining
By default, all Facts are checked and the Rule Chain attempts to collect them all.
In other words, when the Rule Chain executes it goes down every path.
Backward Chaining
Alternatively, Facts can be deselected on the Rule Chain step. This means the paths that were required to gather these Facts are no longer executed.
If the path also included Input Data steps, those Inputs would also no longer be exposed as a parameter on the Rule Chain step.
Adding Flow Controls to a Rule Chain
Flow Control steps in a Rule Chain help route which paths execute in the chain.
Should Continue
The Should Continue step helps to create a typical If/Then Statement Rule. Should Continue steps can have unlimited paths coming in and out of them. If the Rule evaluates True, then all paths coming out of the Should Continue step will execute. Alternatively, if the Rule evaluates False, then paths coming out of the Should Continue step no longer execute.
True-False Rule
The True-False Rule step also allows for the creation of an If/Then Statement Rule that does not return Data. The step can have unlimited paths coming in, but only a True and False path is available coming from the step.
If the Rule evaluates True, only the True path is taken. If the rule evaluates False, only the False path is taken.