Table of Contents

Declare expression rules using the TOP or PARENT keyword depend on existing pages to run

Question

In a Declare Expression rule that references a property using the topkeyword, what happens when, at runtime, a page that is mentioned in the property reference does not exist?

 

Summary

The Target Property of a Declare Expression rule can be defined at either the top-level page or at one of the embedded sub-pages of a clipboard page of the top-level class.

Keywords are available to use in property references. For example, the top keyword causes the system to look in the top-level page that includes the current page..

You can use the top. keyword at various levels of embedded pages (see Example) to identify properties on the primary page. However, for some Declare Expression rules that are defined with a Page Context, the expression may not recalculate after a top input property has been modified, if there are no pre-existing embedded pages for each level of the Page Context.

Your application should ensure that embedded pages are present at each level, if a Declare Expression rule:

  • has a Page Context
  • has a reference to a "top." property

Response

The clipboard contains the following structures when a new General Task is opened in the class PegaSample-Task:

The top-level user page .pyWorkPage, is of class PegaSample-Task, and contains values for these two properties:

  • pxCreateOperator
  • .pyWorkParty( ) - a Page Group property of class Data-Party

The .pyWorkParty group values include:

  • • Originator (class Data-Party-Operator)
    • Organization (class Data-Party-Org)

In addition, the following properties are defined in class Data-Party:

  • • .pyAddress
    • .pyCompany
    • .pyAddresses( ) - a Page Group property of class Data-Address

The .pyAddresses group values include:

• Email (class Data-Address-Email)

In addition, the following properties are defined in class Data-Address:

  • •VerifyOperator
  • .pyEmailAddress

A Declarative Expression is defined in this appliccation. When a user creates a new General Task, the system compares the ID of the operator creating the Task with the email address of the Originator party, testing whether they are the same. If they are not the same, the system sets the .VerifyOperator property to true, so that the operator will be verified.

Set Property .VerifyOperator whenever the property .pyWorkParty(Originator).pyAddresses(Email).pyEmailAddress does not equal .pxCreateOperator

Suggested Approach

When a Declare Expression rule has a Page Context, then at runtime the system looks at all the property references in the Declare Expression under that Page Context. In the example above, the system looks for both .VerifyOperator and .pyEmailAddress in the Data-Address class.

Using the above example, the Target Property .VerifyOperator above has:

  • Page Context: pyWorkParty( ).pyAddresses( )
  • Expression: .pyEmailAddress != top.pxCreateOperator

The goal of this expression is to have .VerifyOperator in each embedded page under .pyAddresses( ), to determine whether to verify an operator, based on the work object's creator.

When a work object is created, the expectation is that when the form is submitted, .pyAddresses().VerifyOperator is set, to either true or false.

However, if there are no page elements defined in the .pyAddresses( ) Page List, then the expression won't execute (in other words, if the Email page of class Data-Address-Email didn’t exist). This is because forward chaining cannot create embedded pages. If there are no pages under .pyAddresses( ), there's no context in which to execute the expression.

Declare Expressions that use top or parent with a Page Context do not execute unless there is at least one pre-existing embedded page at each level of the page context.

If the system encounters this situation, the expression does not execute, and no error is displayed. If your application relies on this expression to trigger other actions, that other processing does notoccur.

Take care in your applications to verify that all the necessary data is present on the clipboard before trying to perform this kind of calculation.

 

Additional information

Troubleshooting: Declare Expression rules fail due to missing Page Context pages 

Suggest Edit

66% found this useful

Have a question? Get answers now.

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