Back Forward How to create a custom rule type

zzzYou can create a custom rule type (a class derived from the Rule- base class) and cause Process Commander to execute a custom activity that implements instances of the rule. Custom rule types are helpful when you use Process Commander to build a software product for redistribution, rather than an application used only in one organization.

For details of this procedure, consult the Technical Resources publication. This topic outlines the steps of the process.

1. Plan and design

Determine and document the capabilities of the new rule. Identify the fields to appear on the form, and the algorithms and logic that implements the new rule as it runs.

2. Create the rule type class and properties

Determine where to place the new Class object within the Rule- class hierarchy, to maximize reuse of existing standard properties, activities and so on. Create the class and any needed custom properties.

3. Create a rule form

Using the Save As function, copy an existing Form File rule of a similar Rule- class to create a starting form. Use the Form Builder to modify the form to reference the correct class and properties, with labels and layout that matches your design.

4. Create a validation activity

Create an activity of type Validate to validate values for the rule.

5. Build the activities

Create activities to open, save, and validate a rule instance, and to implement the rule.

6. Complete the rule type infrastructure

Use the Rule instruction (or equivalently the PublicAPI Java method doActivity()) to execute the implementation activity.

tools.doActivity(StringMap ruleKeys,
    ClipboardPage newParameterPage,
    ClipboardPage newPrimaryPage )

7. Create a database table

As a best practice, store all instances of a custom rule type in a dedicated table in the PegaRULES database. This allows control over exposed columns without affecting exposed columns in standard tables.

  1. Create an SQL table that has at least the exposed columns of the standard pr_rule table.
  2. Expose additional columns as required.
  3. Create a database table instance (Data-Admin-DB-Table class) linking the Rule- class with the table.
  4. Create database indexes for the new table similar to those for pr_rule, to support rule resolution.

See Pega Developer Network article PDNPRKB-17585 Save custom rule types in a dedicated table in the PegaRULES database. For general information on standard tables for rules, see Working with the PegaRULES database — Tables for rules.

Definitions Rule- base class
Related topics End-Validate method
Form Builder basics
Start-Validate method
Using the Rule instruction to implement a custom rule type

UpTechnical category