Creating Custom Rule Verbs Using Rule Engine Extension
  • Updated on 05 Mar 2019
  • 3 minutes to read
  • Print
  • Dark
    Light

Creating Custom Rule Verbs Using Rule Engine Extension

  • Print
  • Dark
    Light

This tutorial demonstrates how to use a Rule Engine Extension to evaluate Rule Flow behavior using custom verbs. TheFlow Behavior Type is used to create a custom verb for Rules with a Flow. This type of Flow can have an Input and has to Output either a True or False Boolean Type.  In this demonstration, the Rule Engine Extension Flow behavior is used to create (emailaddressisinlist) verb for the Rule Engine . The Flow will have String Input (emailaddress), then it will query Decisions Accounts and check if the emailaddress Input matches any of the records in the email address accounts.

Example:

Begin in thedesigner Folder by selecting Create Flow on the Folder Actions Panel and Name the Flow. In the Properties Tab in theSettings section under Behavior Type select Rule Engine Extension to set the Flow behavior. Proceed to the Flow Designer and begin building the Flow .

2018-09-18_154941.jpg

Steps:

  • Start Step (Email Address in) : Located in the Flow designer
  • Fetch Entities (Fetch Account by Email Address): Integrations > My Integrations > Databases > Mock Data (Database) > dbo.person (Table)
  • Create Data (Set Output Boolean to TRUE): Data>Create Data Step
  • Create Data (Set Output Boolean to FALSE): Data> Create Data Step
  • End Step (Resul Boolean): Located in the Flow designer

flow-with-caption.jpg

Start Step

In the Flow Data section underFlow Input Data select Show Editor to add aData Definition. Create a Name and define its Type as String. To save and exit selectClose.

  • Name : Emailaddress
  • Type: String

13.jpg

Fetch Entities Step (Fetch Account by Email Address)

In theEntity Fetch Definition under Type Name select [Account] DecisionsFramework. UnderFetch Criteria selectAdd New , to add a data definition (Figure 4).

*Note: select the pencil icon to edit Fetch Criteria.

  • Field Name: emailAddress
  • Query Match Type : Equals

21.jpg

Create Data Step: Set Output Boolean to TRUE

  • Name: output
  • Type: Boolean

4.jpg

In the Inputs section set the output to Constant and check the box to run the rule as TRUE
32.jpg

Create Data Step: Set Output to FALSE

  • Name: output
  • Output: Boolean

2018-09-25_133311.jpg

In the Inputs section set the output toConstant and uncheck the box to run the rule asFALSE, (Figure 8).
2018-09-25_133359.jpg

End Step

On the End Step in the Data section under Output select Show Editor and create a data definition. Create aName (Result) and choose the Type (Boolean). In the Inputs section next toResult choose Select From Flow and Pick output.

  • Name : Result
  • Type: Boolean

2018-09-25_135053.jpg

After the Steps are configured in the Properties Tab under Common Properties, connect the pathway. Complete the flow by selecting Debug and verify that the flow works properly. T his completes the Creating Custom Verbs Using Rule Engine Extension, save and close Flow Designer.

Create Rule

The Flow can now be evaluated using aRule . Start by creating a Rule in the designer Folder to test the Custom Verb created above. Test theRule Engine Extension using a Rule. Select Create Rule > Create Rule from the Folder Actions Panel. When the Rule designer opens in the Rule Data section select Show Editor to add Rule Input Data . Then Name the input and define its Type as String . SelectClose to save and exit.

2018-09-25_141521.jpg

Create the Rule Phrase that will evaluate the Rule Engine. Pick [Select Data Element] and choose CompanyName, next select [Pick Verb] and expand theEvaluate category and choose isCustomerInDatabase. Leave**[no parameters]** as is and complete the rule.

2018-09-25_141858.jpg

This completes the Rule design . Next, create Unit Tests for this Rule . On the top panel of the rule designer select Debug to debug the rule.
2018-09-25_141957.jpg

Under Rule Example Data, select Add New. In theAdd Unit Test area, add an existing Company Name from the database , name the Unit Test (Pass) and expect it to Pass . Then, select Save.
2018-09-25_143412.jpg

Now Create a new Unit Test , select Add New . Name the unit test (Fail) and expect the Rule to Fail. To test theUnit Test Rule use a company name that does not exist in the database. This example uses the name (The Famous Company) . and as CompanyName input we use a CompanyName that does not exist in our database . Click Save.

2018-09-26_101559.jpg

Test the Rule and Run All Unit Tests. The results should verify that both Unit Tests executed as expected (firs-Passes, second -Fails).
2018-09-25_144201.jpg

Was this article helpful?