LinkedIn
Copied!

Table of Contents

More about Constraints rules

Version:

Only available versions of this content are shown in the dropdown

Conflicting constraints

Multiple constraints that are impossible to meet are neither detected or rejected, such as A > B and B > A. Both properties are marked as not valid each time either is changed.

Primary page

During execution of a constraints rule, the page on which the rule operates temporarily becomes the primary page. The page keyword PRIMARY and the results of the tools.getPrimaryPage() PublicAPI method reflect this change. When the constraints rule completes, the primary page of the calling activity resumes as primary.

Alias Function rules

The contents of the selection lists on the Constraints tab depend on property alias rules and alias function rules.

Change tracking exceptions

The constraints are tested when a property value on the primary page (the page that matches the Applies To key part of the rule) changes. The following do not cause the constraints to be evaluated:

  • Changes to properties on other pages referenced in the Pages & Classes tab
  • Saving a rule form that contains a property on the page
  • Retrieving a property value with the Obj-List or Obj-Browse method
  • Retrieving a property with the RDB-List method, unless the ApplyDeclaratives parameter of that method is selected

Workstation display of constraint failures

When appropriate, your application can display constraint rule violations immediately as a user changes an input value on a user form or flow action form, rather than later when the form is submitted. The user can see the constraint message immediately.

For example, the constraint may require that the Due Date field be at least a week after the Start Date field. As a user enters and revises work item data, the constraint is checked immediately as user focus leaves either input field.

This feature can improve user productivity and accuracy, while also reducing the number of server interactions and HTTP traffic required to complete a valid input form. Consider whether and where such interactive checking may simplify the user's task of completing complex input forms in your application.

To implement this capability:

  1. For best results, use this feature on flow actions or harnesses that use the SmartFrames layout and JSP tags rather than declaratives.
  2. Include the properties involved in the constraints on the same flow action form, or on the same user form (in the same or different sections). (Don't place the input in the flow action form and the target in the harness form or vice versa.)
  3. Select the Enable Expression Calculation? box on the HTML tab of the Flow Action form or Harness form.
  4. Test.

This feature is based on AJAX technology.

You can view the generated Java code of a rule by clicking Actions View Java . You can use this code to debug your application or to examine how rules are implemented.

Testing and debugging constraints rules

Using the Tracer, you can watch the evaluation of a constraints rule. Start the Tracer and select a requestor session. Click Settings and check the Declare Constraint box in the Event Types to Trace section. Also check the RuleSet that contains the rule to be traced.

The statistic Tracked Property Changes on the full details page of the Performance tool shows how many property changes have occurred (for the current requestor since log-in) that are tracked for declarative rules computations. You can modify the prlog4j2.xml file to log additional details about tracked property changes. See the Pega Community article How to determine which properties are tracked for declarative processing.

OnChange activities

Constraints rules, like Declare Expression rules, do not evaluate during the execution of an OnChange activity.

Did you find this content helpful?

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.