Custom guardrail warnings

From PegaWiki
This is the approved revision of this page, as well as being the most recent.
Jump to navigation Jump to search

Custom guardrail warnings

Description Custom guardrail warning configuration, explanation and examples
Version as of 8.4
Application Pega Platform
Capability/Industry Area Enterprise Application Development



Custom guardrails can be built and called by the OOTB placeholder CheckForCustomWarnings, which is called on each click of Save.

Use case examples[edit]

During development it may be beneficial to guide development processes and enforce best practices by adding warnings and messages at the time of rule creation or modification. These warnings may then be removed post development or considered to remain for consistency in future development.

For example, it is discovered that recently developed rules have inconsistent use of activity step description and the rule History field is either blank or copy/pasted in the Usage field. It is also desired to have spacing between the words in the Label ID and that all commented code be evaluated for removal. Additionally, developers may wish to have the "Allow Direct Invocation" configuration tracked for testing and development.

Before you begin[edit]

Is it necessary to plan anything in advance, or are external steps using other tools required to achieve the goal? If any specific configuration procedures (how-tos) exist on the Pega Community pages, you can link to those assets here by providing the URL.

Process/Steps to achieve the objective[edit]

This example will create varying messages as structured in the below diagram 1.1.

Illustration of custom guardrail configuration
1.1 This illustrates the order of steps and activities called for the custom guardrail examples.

Extend placeholder[edit]

  1. Perform a Save as on the OOTB placeholder activity CheckForCustomWarnings in Rule- or the class of the rule to be evaluated. This gets called on every click of Save.
  2. Create an activity such as CheckForExtendedWarnings in the class of the property to be evaluated.
  3. On the CheckForCustomWarnings activity step, call CheckForExtendedWarnings.
  4. On the CheckForExtendedWarnings activity step, set the Step Page, Loop and When conditions and call the Function: Add a message to a page using [Name of message rule].
  5. Create a Message rule (called from the previous Function) and set the Category, Severity and Application Impact using drop-down selections. Type the message to be displayed in the Message field.

Direct invocation[edit]

Display warning conditional on checkbox property.

  1. (2.1) Two steps use the methods Property-Set and Call-Function.
    Activity for Direct Invocation warning
    2.1 Two steps use the methods Property-Set and Call-Function.
  2. (2.2) Set a When condition - "Enable conditions before this action".
    Direct Invocation When Condition
    2.2 Set a When condition - "Enable conditions before this action."
  3. (2.3) Message created in @baseclass and called from a step in CheckForExtendedWarning.
    Direct invocation Message
    2.3 Message created in @baseclass and called from a step in CheckForExtendedWarning.
  4. (2.4) TEST: The box "Allow direct invocation from the client or a service," when unchecked, should display a warning.
    2.4 For testing, the box "Allow direct invocation from the client or a service," when unchecked, should display a warning.
    When Save is clicked on a rule, conditions are checked and a warning displays.

History usage and description[edit]

Display a warning if the description and usage are null.

  1. (3.1) Two steps use the methods Property-Set and Call-Function.
    History activity steps
    3.1 Two steps use the methods Property-Set and Call-Function.
  2. (3.2) Set a When condition on the Call-Function step.
    History when condition
    3.2 Set a When condition on the Call-Function step.
  3. (3.3) Message created in @baseclass and called from a step in CheckForExtendedWarning.
    History message
    3.3 Message created in @baseclass and called from step in CheckForExtendedWarning
  4. (3.4) TEST: Leave either the Description or Usage fields blank and click Save.
    History message test
    3.4 TEST: Leave either Description or Usage fields blank and click Save

History usage and description identical[edit]

Display a warning if description and usage are identical.

  1. (4.1) Two steps use the methods Property-Set and Call-Function.
    Identical Description and Usage Activity Steps
    4.1 Two steps use the methods Property-Set and Call-Function.
  2. (4.2) Set a When condition on the Call-Function step.
    Identical Description and Usage When Condition
    4.2 Set a When condition on the Call-Function step.
  3. (4.3) TEST: Copy/paste identical content into the Usage and Description fields. On save, a message is displayed.
    Identical Description and Usage Message.
    4.3 Identical Description and Usage Message.

Label same as ID[edit]

Displays a warning when the label is not spaced between words similarly to ID.

  1. (5.1) Two steps use the methods Property-Set and Call-Function.
    Activity steps for label same as ID
    5.1 Two steps use the methods Property-Set and Call-Function.
  2. (5.2) Set a When condition - "Enable conditions before this action."
    Label Same As Id When Condition
    5.2 Set a When condition - "Enable conditions before this action."
  3. (5.3) Message created in @baseclass and called from step in CheckForExtendedWarning.
    Label Same As Id Message
    5.3 Message created in @baseclass and called from the step in CheckForExtendedWarning.
  4. (5.4) TEST: Edit the label to match the ID.
    Label test
    5.4 TEST: Edit the label to match the ID.

Commented steps[edit]

Displays a warning when activity steps are commented out (//).

  1. (6.1) Two steps use the methods Property-Set and Call-Function.
    Commented code steps
    6.1 Two steps use the methods Property-Set and Call-Function.
  2. (6.2) Set a When condition - "Enable conditions before this action".
    Commented code when condition
    6.2 Set a When condition - "Enable conditions before this action".
  3. (6.3) Set parameters in parameter tab.
    Parameter tab
    6.3 Set parameters in the Parameters tab.
  4. (6.4) Check each step recursively. (See diagram 1.1 for illustration.)5
    Recursively check steps
    6.4 Check each step recursively.
  5. (6.5) Message created in @baseclass and called from step in CheckForExtendedWarning.
    Commented code message
    6.5 Message created in @baseclass and called from a step in CheckForExtendedWarning.
  6. (6.6) TEST: Comment step and save. Warning will display.
    Commented Code Test Message
    6.6 TEST: Comment a step and save. Warning will display.