Table of Contents

How to create a rule warning


Introduced in V4.2SP6, rule warnings serve to warn developers when they create and save a rule that that may contain unwanted or risky conditions. Rule warnings are advisory only; they do not prevent the developer from saving the rule.

This article describes the operation of rule warnings and includes a procedure that allows you to create additional warnings that are specific to your environment or development practices. You can also override the standard behavior of the Application Preflight tool. 

Suggested Approach

Unlike validation errors, warning messages do not prevent the Save operation from completing.

For example, this activity has two warning messages, but can be saved and executed.


Warnings are useful for developers to identify situations that are not aligned with best-practices.

You can review a complete list of warnings for an application with the Application Preflight facility. This image shows a partial Application Preflight display. Red bars identify rules with one or more warnings.


To add or modify rule warnings, override the empty activity named CheckForCustomWarnings. This activity is called immediately after the standard activity CheckForWarnings and is expressly designed to allow you to add warnings. Since your activity rule will belong to an application RuleSet, make sure that all the developers that you want to see the warning include that RuleSet in their RuleSet lists.

A warnings activity has the rule that is being saved as its primary page. For example, activity Rule-Obj-FlowAction.CheckForWarnings checks the value of the property pyAutoHTML, and adds a warning condition to the rule if the flow action is not auto-generated — that is, if pyAutoHTML is false.


To add a warning, call the standard function rule addWarning. Examine and follow the standard activity Rule-Obj-FlowAction.CheckForWarnings as an example. This function has seven parameters:



Short name of the warning (this is what appears in preflight)


Message to show on the rule form


Extra details to show in preflight (for example, in warning for Java the number of lines of Java is a detail)


Type of warning. This can be used to group warnings together in a report (for example., all the warnings for Performance issues). These values are suggested:

  • Performance,
  • BestPractice
  • DataIntegrity (the rule may be using Commit incorrectly)
  • Deprecated
  • Logic (user having a decision rule that has unreachable parts)


Number from 1 to 3 where 1 is most serious


Page to add warnings to, pass in the primary page


In order to support V4 Application Preflight, sets the value of strListPageName by getting the value of a parameter named resultsPageName


You can control which warnings appear during rule form save and display by overriding the standard decision tree rule Embed-Warning.ShowWarningOnForm. (However, even when you suppress the warning during the Save operation, the warning is still stored in the saved XML and will appear in the Application Preflight display.)

The decision tree rule examines information about a warning (name, severity level, type, etc) to decide whether to present the rule (return true) or not (return false). For example, if the decision tree rule is changed so that when the name is "Java", the tree returns false, then Java warnings for activities are no longer displayed on the rule forms. You can also override the standard decision tree logic in other ways — for example, not display any severity 3 warning messages.



You can add a CheckForWarnings activity that with an Applies To key part that is an abstract class such as Rule- , but keep in mind that this activity is not automatically called for rule types that have a more specific CheckForWarnings activity in place.

Also, be aware of rule types that inherit from rule type that you updated. For example, do not override the standard Rule-Obj-Activity.CheckForWarnings activity to add warnings to validate rules (Rule-Obj-Validate) even though the validate class inherits from the activity class . Instead, override the empty placeholder activity Rule-Obj-Validate.CheckForWarnings.

Technical details

Warnings work by appending the warning details to a Page List property named pxWarnings which gets is part the XML document form of each rule. The activities CheckForWarnings and CheckForCustomWarnings are called as part of the StandardValidate activity which is called by Save, SaveAs, etc. A standard Declare Index rule named Rule-.Warnings copies the warnings into to the PegaRULES database table named pr_index_warnings.

The (Version 5.X) Application Preflight display uses reports based on the pr_index_warnings table. The Application Preflight display contains warning information only for rules that have been saved in a Process Commander system with version V4.2SP6 or later.

If you add a new warning test, or import rules into a system from a ZIP archive, warnings on such rules do not appear until the rules are subsequently saved . You can use the Revalidate and Save tool to resave many rules in a single operation.

V4 Preflight Tool

An alternative to the V5.X Application Profile tool is the older V4.2 Preflight tool, which lists all the rules in an application, runs CheckForWarnings and CheckForCustomWarnings against them, and displays all the resulting warnings.

This older facility can be slow since it has to open every rule. In addition, it shows warnings only on those rule types that are listed in the Local List array (on the Table Edits tab) of the Rule-.pyGuardRailRules property.

100% found this useful

Have a question? Get answers now.

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