- Updated on 08 Mar 2019
- 6 minutes to read
Flow andRule Sets are a common set of rules and flows that can be parameterized or customized based on context without the need to copy or rewrite them. The Rule Set allows you to define a number of rules or flows that can work together. These define the process that you would like to follow that will be known as the base set.
Once a Rule Set is defined in the base set, a subset can be created. This allows a change in the process to be added to a group of Flows and Rules without the need to recreate each item. The subset has the ability to alter input data, which rules are applied, and which processing elements should remain. The process will stay the same, but the context of each subset can be modified for the situation.
An example of this would be through an Auto Insurance processing company . By defining a base flow set, you can set the process of how you would like to approve insurance applications and apply rules to the data. However, with a large company, there may be a difference in how you would like to approve the application. For example, the application approval requirements may differ depending on owner’s car specifications. Although the main flow approving process is the same, you can specify the subset and change some of the context.
Here is an example of how to create a flow set:
Note : in order to use Rule Sets and Interceptor Rules , Decisions.FlowSets Module should be installed. To learn how to install Module in Decisions please click here .
After Flow Sets Module is installed, create Application Structure to use in the Rule Set . In the Designer Folder, createFlow Structure from Datatypes/Database > User Defined Types on Folder Actions Panel.
In the resulting window, Name our structure and tab through to add data members and their type to the structure.
When all desirable Data Members added, select SAVE to save the structure.
Note: The Birthday structure member is of a Date type.
Next, in the Designer Folder from All Folder Actions, selectCreate Rule > Create Rule/Flow Set .
In the resulting dialog, Name the Rule Set and select CREATE .
A Sub Folder for the Rule Set is created by the System in the Designer Folder . Navigate to this Folder .
In the Rule Set Folder , select Setup Rule Set on the Folder Actions Panel.
In the Edit Flow Template Data window we make the following configurations…
Logical – apply logical check to data. Best used for validations and data check.
Data Return – best use for data manipulations.
Scoring – used for statistical purposes when need to do manipulations on the rule results count.
Run All – run all Rules/Flows in the Set
Stop On First True – terminate Set execution on first Rule evaluating as True
Stop On First False - terminate Set execution on first Rule evaluating as False
Template w/ Instances – used when we want to create a base Set of Rules and then create specific sub-sets of Rules.
Instance – used when we want to create just a Set of Rules without specific sub-sets.
In theInputs Setup, define Rule Set Inputs . These Inputs will be passed into each Rule/Flow in the Set . Select Add New link to add an Input .
In theAdd Inputs window, Name the Input and pick a Type of the PolicyApplication Structure that was created previously in this tutorial.
There are multiple Data Inputs to add. MinIncome (Decimal), MaxIncome(Decimal), olderThan(TimeSpan), and youngerThan(TimeSpan). Next set the Rule Set Type to Template w/ Instances.
When the Rule Set is configured select SAVE to save it.
Next, start creating Rules for the Set .
From the Folder Action Panel select Add Rule > Evaluation .
There are two types of Rules that can be created in Rule Set : Evaluation and Action . If data needs to be validated or checked (apply logic) use Evaluation type; If data needs to be manipulated or changed – use Action type.
In the resulting window name the Rule and select Create Rule .
The Rule has Application input by default. Build the Rule Phrase using Application properties. In this case build a Rule to check if applicant is currently insured.
The first Rule looks as following:
The logic for this Rule is next:
Use the Rule input of older than to Configure Offset for Compute Date.
And this Rule design completed.
Next, create Denial Rule that looks as following:
Again, use an additional Rule input (youngerThan) for Computing Date .
Because the Rule Set is configured to be a Template w/ Instances , add Instances of this template. In the Instance create additional (specific) Rules. Select Create Instance button on the Folder Actions Panel in Rule Set Folder.
In the resulting dialog, Name the Instance and select CREATE . System creates an Instance Sub Folder.
For this example create two Instances : Policy A and Policy B . Navigate to thePolicy B instance.
For this instance all base Rules will be ran automatically. Application is an input by default. Create an Evaluation Rule for this Instance .
This Instance will be specific because this Rule will define additional requirements and data validation. Design a Rule that checks vehicle horse power and four wheel drive capability.
The Rule Set is completed now. Close it and navigate to the Designer Folder and build a Flow to test this Rule Set.
In the Designer Folder, select Create Flow from the Folder Actions Panel.
Then, Name the Flow and select Create to proceed to the Flow Designer .
In the Flow Designer add Run Rule Set step from Flows, Rules, Forms and Reports > Rules category and connect its outcome to the End step in the Flow .
The Rule Set will require an Application to Evaluate, create an Application as an input to the Flow . Select Start step on the workspace and select Add New link in the Inputs section.
As described, Name our Input Data and define its type of PolicyApplication .
Next, select Run Rule Set step on the workspace. In the step Properties > Rule Set chose the Pick link and select the created template, PolicyRuleSet.
Next, Navigate to the PolicyB instance folder. Select Manage > Get Rule Set ID.
Copy the ID from the popup.
Back in theRuleSetFlow, with the RuleSet Step selected, navigate to Properties > Rule Flow Set ID. Set to Constant and paste the copied ID.
This completes the Flow . Select Debug Flow link on the top panel of the Flow Designer to test the Flow .
In the Create New Session window, select the Input Data selector.
In the resulting window populate Application fields with data and select Ok .
Next, select Run
Flow executes in the Debugger with no issues. Confirm that Run Rule/Flow Set step outputs PolicyRuleSet evaluation results for each Rule in the Set .