Back Forward How to classify and select rules based on Custom Field values

Basics

zzzCustom fields offer application developers a flexible way to associate a set of labels and values with a rule, for classification or to supplement other facts in the rules.

Custom Fields offer a flexible facility for categorizing rules in an application, or for supplementing rules with metadata. These fields have multiple uses, some of which are noted here.

For example, a file containing design notes, testing notes or change order details can be linked to a rule as the value of a Custom Field.

As another example, an e-commerce application may include three discount plans that all apply to orders that meet certain dollar amounts or other criteria. The plans may be codified in decision tree rules named Animal, Vegetable and Mineral. However, from time to time, the scope or coverage of each plan (not the discount computation) may change. Managers may alter the value of a Custom Field to help the application decide which rule to apply.

Associating Custom Fields and field values with a rule

Each Custom Field has two parts, a name and a value. The value may be a text string or a file.

Developers can add or delete new Custom Fields for a rule instance, and can change the values. See How to complete and use the History tab of a rule form.

Updating Custom Fields of type Text

When a rule instance contains a Custom Field of type Text (rather than File), any user or developer who can update the leftmost tab of the rule can also update the text value.

When a decision rule, for example, is delegated to a manager to maintain, the manager can update information in the leftmost tab of the rule and can change the value of Custom Fields. Custom fields appear at the bottom of the header tabs of the rule form. (From the header of the form, you cannot add or delete Custom Fields.)

See:

Overriding the default presentation of Text Custom Fields

Your application can customize the presentation of the Custom Fields area on the header of a rule form, to provide audience-specific labels and validation.

  1. Create an HTML rule by copying the standard rule Embed-CustomFields.defaultFields into your application, with a Stream Name of your choice.
  2. Update the HTML text to provide the desired presentation, including layout, styles, and labels. The HTML code in this rule is eventually included within other rules; it does not define a full document.
  3. Copy the standard decision tree rule named Rule-.getCustomStreamName into your application RuleSet, retaining both key parts so that your rule overrides the standard rule.
  4. Update the copied decision tree rule to choose the your custom HTML rule rather than the standard rule when desired.

Searching for Custom Fields by Value

A developer can search for rules that contain a specific Custom Field value. Select View > Rules > Find by a Custom Fields to start a wizard.

To filter by a custom field value, the custom field must be a database column in table pr_index_customfields. If you add new custom fields and you want to report on them, expose them as columns.

By default, this facility only searches rules types that belong with the Decision category. Your application can override this behavior by overriding the standard list view rule named Rule-Obj-Class.getCategorizedRules.

Internals

The system stores custom field links as instances of the Index-CustomFields class, as elements of the @baseclass.pyCustomFields property, a Page Group property. Physical storage within the PegaRULES database uses the pr_index_customfields table.

For Text types, the system saves both the name and the value with the rule. When you upload a file as the value of a custom field, Process Commander automatically creates a binary file rule instance containing the file and links the rule to the binary file rule.

New Custom Fields can be created by those who have the ability to create new properties.

Related topics About the Advanced Search tool
Working with the PegaRULES database — Link- and Index- Tables

UpDeveloper portal basics