Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

Creating Declare Expression rules

Updated on November 15, 2021

Declare Expression rules - Completing the Create, Save As, or Specialization form

Records can be created in various ways. You can add a new record to your application or copy an existing one. You can specialize existing rules by creating a copy in a specific ruleset, against a different class or (in some cases) with a set of circumstance definitions. You can copy data instances but they do not support specialization because they are not versioned.

Create a Declare Expression rule by selecting Declare Expression from the Decision category.

Note: Because declarative expressions extend the definition of a property value, use nouns in the declarative expression names for better distinction from property values.

Key parts:

A Declare Expression rule has three key parts:

FieldDescription
Apply to Select an internal or external class for this rule. The properties to be calculated can be in this class or in the class of an embedded page.

If you select a class derived from the Embed- base class, leave the Page Context key part blank, which creates a context-free expression.

Do not use a Rule-Declare- * class or any ancestor of the Rule-Declare- class (including @baseclass ) here. You cannot use a class derived from the Code- class here.

Do not create rules with Work- as the Apply to class. Instead, choose a class derived from Work-, such as a work type or work pool container class. In many cases, the Save As dialog box defaults a container class for this field. See Copying standard rules from the Work- class.

Target Property

Select a property that appears somewhere within the scope of the class in the Apply to key part. Precede the name with a period. Select a property of mode Single Value, Page, or Java Property.

Do not use a Declare Expression rule to compute a property for which the Cannot be declarative target box (on the Advanced tab) is selected.

Do not use symbolic page names such as primary or steppage here, because they are meaningful only in an activity execution context.

Note: If at runtime the Target Property resides on an embedded page rather than a top-level page, complete the Page Context key part before completing the Target Property key part.
Page Context

Optional. Leave this blank if the Target Property property has mode Single Value and appears directly on a page of the Apply to class, or if you are creating a context-free expression.

Otherwise, identify a Page List or Page Group property reference plus parentheses, starting with a period. Omit any index between parentheses, as the expression applies to all elements. For example, these show correct use:

.Invoices.pyOrders().pyItems().pyItemNames()
.pxCorrSummary()

The length of the value in this field is limited to 64 characters.

Forward chaining does not create embedded pages where none existed before. Declare Expressions that have a non-blank Page Context and that use top or parent keywords do not execute unless there is at least one pre-existing embedded page at each level of the page context. For more information and an example, see the Pega Community article Declare expression rules using the TOP or PARENT keyword depend on existing pages to run.

When a property is the target of two Declare Expression rules — one context free and the second with a context, the second takes precedence over the context free rule, which is ignored. If two context free Declare Expression rules reference the same property using distinct property reference forms (for example workpage.targetproperty and .targetproperty ), the rule with the longer reference is executed; the rule with the shorter reference is ignored.

Rule resolution

When searching for instances of this rule type, the system uses full rule resolution which:

  • Filters candidate rules based on a requestor's ruleset list of rulesets and versions
  • Searches through ancestor classes in the class hierarchy for candidates when no matching rule is found in the starting class
  • Finds circumstance-qualified rules that override base rules
  • Finds time-qualified rules that override base rules

About Declare Expression rules

  • Previous topic Declare Expressions form - Completing the Expressions tab
  • Next topic Declare Expression form - Completing the Pages & Classes tab

Have a question? Get answers now.

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

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us