Rule Extensions Using Rule EngineLast Updated: 07/15/2016 Introduced in Verision: 2.0
This tutorial demonstrates how to use Rule Extensions in Rule Engine. Rule Engine Extension is a Rule Behavior implemented in Decisions 3.2. This Rule Behavior allows to create a Rule that can be embedded in another Rule. It is required to add “anchor” Input in the “Main” Rule in order to use Rule Engine Extension. This “anchor” Input should be the same Type of Data that Extension Rule has as its Rule Input Data.
In this example we will create a Flow that should validate if the Account in the Portal belongs to the Decisions Employee, and then, display all Accounts that passed this validation. In order for the Account to pass validation it should contain decisions.com in the Email Address field. Additionally, it should have a specific Address in the Contact Info. Because Address is a complex Data Type, we will create a Rule Extension that will check if the Address is valid for the Account.
First, we need to create a Complex Address Data Structure. In the Designer Folder we select Create Datatypes > Defined Data Structure [Advanced] option from Folder Actions.
We name it Address and add four Data Members. Click Ok to save and close Add DefinedDataStructures window.
Next, we are going to create our Extension Rule. In the Designer Folder we click Create Rule > Create Rule on the Folder Actions Panel.
In the resulting pop-up window we Name our Rule and select Rule Engine Extension from Behavior dropdown. Click Create to proceed to the Rule Designer.
In the Rule Designer we click Add New link to add new Rule Input Data.
In the Add Rule Input Data pop-up window we Name our Input and select Address Data Structure that we have created for this tutorial as its Type. Click Ok to save and continue.
Back in the Start Rule Wizard we click Add New Rule Step…
In the Rule Phrase Builder we expand Address Rule Input, select City Data Member and click Next.
Then, we expand Equals Verb category select Is and click Next.
Finally, we define Constant City Value for our Address and click Done to complete this Phrase.
In the Resulting pop-up window we click Add New Rule Step to create another Rule Phrase for different Data Member in the Address Input Data.
In the similar manner we add Rule Phrases for each of the Data Members in the Address Data Structure. When completed our Rule should look as following. It will accept Address Data and return True if all Data Members match our desirable Address. We can save the Rule and close Rule Designer.
Next, we will create our Main Rule that will use Extension Rule. In the Designer Folder we click Create Rule > Create Rule.
Then, Name the Rule and click Create to proceed to the Rule Designer.
In the Rule Designer we Add New Rule Input Data…
We Name our Rule Input Data. This Rule Input Data have to be the same Type as Input Data for our Extension Rule. We select Address Type. In this case this Rule Input Data will be an “anchor” for our Extension Rule. Click Ok to save and continue.
Back in the Start Rule Wizard we click Add New link to add another Rule Input Data.
Our second input will be of type Account.
Back in the Start Rule Wizard we click Add New Rule Step to start designing our Rule.
In the Phrase Builder we select our AccountAddress “anchor” Input Data and click Next.
Next, in the verb definition window we expand Rule Engine Extensions and pick our Extension Rule as a verb for this Rule Phrase. Click Next to continue.
Our Extension Rule does not take any additional Input Parameters, therefore we click Done to complete this Rule Phrase.
Next, we click Add New Rule Step to add new Phrase.
This time we expand Account Input Data and select EmailAddress field. Click Next to continue.
In the Verb definition we select Contains from the Text Rules category. And, click Next…
This Rule Phrase should validate that Account’s Email Address contains decisions.com. We define this string as a Constant Value and click Done.
This completes our Rule Design.
The Rule should look as following. Then, we can save the Rule and close Rule Designer.
Back in the Designer Folder we click Create Flow on Folder Actions Panel.
Next, we Name the Flow and click Create to proceed to the Flow Designer.
In the Flow Designer we add Get All step from Integrations > All Integrations > Internal Service > Account Service category in the Flow Designer Wizard.
To iterate through the collection of All Accounts we add ForEach Step from All Steps [Catalog] > Flow Management category in the Flow Designer Wizard.
In the resulting pop-up window we select GetAll_Output collection and click Add.
On the Next Outcome from the ForEach Step we add GetAddressForContactInfo step from Integrations > All Integrations > Internal Services > Address Service category in the Flow Designer Wizard.
Then, we add our Validate Decisions Employee Rule from Flows, Rules, Forms and Reports > Rules > [Current Folder] category.
Next, we connect False outcome from the Rule step back to the ForEach Step, and select Show Mapping Editor from GetAddressForContactInfo step Options.
In the Mapping Editor we expand Item outcome from the ForEach Step and connect AccountID Data Member to the contactInfoId field. Then, save and close Mapping Editor.
Back in the Flow Designer we call Mapping Editor for our Rule Step in the Flow.
We connect Item outcome from the ForEach Step to the Account Data Input in our Rule. Then, we use Build Data Mapping type for the Address field.
We expand GetAddressForContactInfo_Output and connect respective fields to the Address Data Members. Click Ok to save and close Mapping Editor.
Back in the Flow Designer we drag and drop into the workspace Add Item To List step from Data > List category in the ToolBox.
We connect this step to the True outcome from the Rule step in our Flow. Then, we connect Done outcome from this step back to the ForEach Step, and select Show Mapping Editor Option for this step.
Data Mapping for this step should look as following…
In order for the New List to be Account  Type we need to change ListType option for this Step.
Finally, we drag and drop Show Form step from Favorite Steps category in the ToolBox.
On the workspace we connect Show Form step to the Done outcome from the ForEach Step, and select Pick or Create Form from the step Options.
In the resulting pop-up window we Name our Form and click Create to proceed to the Form Designer.
This Form designed as following. It has several Label components from Data category to display Title and additional information. Next, it has a Button control from Actions category. Finally, we use Data Grid component from the List category and configure this component to display a List of Accounts. We keep desirable fields to display from the Account Data Type. When finished, we can save and close Form Designer.
Back in the Flow Designer, we connect our Form step to the End Step in the Flow. Next, we call Mapping Editor for the Show Form step.
In the Mapping Editor we simply connect a New List of the validated Accounts to the DecisionsEmployees Data Grid component on our Form. Then, save and close Mapping Editor.
This completes our Flow. We click Debug Flow link on the Top Panel in the Flow Designer to test our Flow.
Note that in Decisions version 3.5 and higher, you’ll need to click on Test Flow to access the Debugger.
Our Form opens in the Debugger displaying a List of validated Accounts. We click Done on the Form.
Diagram Tab in the Debugger indicates that our Flow was executed with no errors.
If we check Contact Info for the validated Accounts from our Flow…
We can confirm that they have the same Address that we used in our Extension Rule for validation.