Creating a Rule Chain
  • 27 Jun 2024
  • 3 Minutes to read
  • Dark
    Light

Creating a Rule Chain

  • Dark
    Light

Article summary

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:


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:

  1. Define Inputs to be mapped into the Rule Chain
  2. 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.


Defining the Inputs will expose Input variables on the Rule Chain, similar to a Start step in a Flow.

No Supplied Input Data

Two things happen when Data is not supplied to an Input.

  1. All steps connected to a Null Input Data step do not execute.  Input Data steps create a dependency on all connected steps.
  2. 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

The various types of Decisions Rules may be used in Rule Chains via the Rule steps. 

Decisions Rule Steps

Note: these steps do not require mapping.
By design, Data is automatically mapped into connected Rule steps. To use Rule steps in a Rule Chain:
  1. From the Rule Chain Designer, add the desired Rule step from Toolbox > RULE CHAINING [DMN] to the workspace.
  2. Drag out one of the connection points from the Input Data to the Rule step. 
  3. Select the Rule step then click the EDIT button. 
  4. Define the Rule as usual by utilizing the connected Input Data as the Rule Inputs. 

Outputting Data within the Rule Chain

Rule steps, just like in a Flow, evaluate data and Output a result within the Rule Chain. If the rule evaluates True, the result data can be used by other connected steps in the Rule Chain. The screenshot below represents a Statement Rule that Outputs a String value.

Note:
By default, connected Rules only execute if the Rule produces a result.

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.

Note that Flow Controls do not return Data or produce Facts.


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.

For further information on Rules, visit the Decisions Forum.

Was this article helpful?