About Declare Expression rules
Use Declare Expression rules to define automatic computations of property values based on expressions.
The following tabs are available on this form:
Forward chaining
Often, target property values are computed automatically each time any of the other input values in the expression change, or when a value for this property is accessed, changed, or using other criteria. This technique is known as forward chaining.
For example, you can declare that a property named Order.TotalPrice is always the sum of:
- OrderLine(1).TotalPrice
- OrderLine(2).TotalPrice
- OrderLine(3).TotalPrice
and so on. You can also declare that OrderLine().TotalPrice is always equal to .Quantity multiplied by.UnitPrice.
Backward chaining
In an activity, the Property-Seek-Value method can access the computational relationships among properties in a Declare Expression rule to identify source values needed to compute a missing property value. This technique is known as backward chaining.
For example, consider a single Declare Expression rule defining Circumference as 3.1416
times Diameter with Change Tracking set to
Whenever used
. This rule can be
used in either forward-chaining or backward-chaining mode:
- If step 3 of an activity causes the value of Diameter to be set, an updated value for the Circumference property is available at the start of step 4 (forward chaining).
- If step 1 of another activity uses the Property-Seek-Value method with Circumference as the target, and no value for Circumference is found, the system seeks a value for Diameter (backward chaining).
Access
Use the Application Explorer to access the Declare Expression rules that apply to work types in your application. Use the Records Explorer to list all Declare Expression rules available to you.
After you complete initial development and testing, you can delegate selected rules to line managers or other non-developers. Consider which business changes might require rule updates and if delegation to a user or group of users is appropriate. For more details, see Delegating a rule or data type.
Category
Declare Expression rules are instances of the Rule-Declare-Expressions rule type. They are part of the Decision category.
- Declare Expression form - Completing the Change Tracking tab
Complete this tab to determine the conditions that cause automatic recomputation of the expression. These conditions affect how often the computation on the Expressions tab is performed.
- Declare Expressions form - Completing the Expressions tab
On this tab, record the computations for the target property identified in the key.
- Declare Expression rules - Completing the New or Save As form
Declare Expression rules - Completing the Create, Save As, or Specialization form
- Declare Expression form - Completing the Pages & Classes tab
Use the Pages & Classes tab to list the pages referenced in the Expression tab. See How to Complete a Pages & Classes tab for basic instructions.
- More about Declare Expression rules
This topic provides additional information about declare expression rules.
- Unit testing a declare expression
You can test a declare expression individually, before testing it in the context of the application that you are developing. Additionally, you can convert the test run to a Pega unit test case.
- Declarative network
The declarative network is an internal data structure that defines the relationship between properties and whose value is automatically (declaratively) calculated based on changes to other property values. You can configure and visualize complex relationships using the Declarative Network display, which shows the target property and all potential inputs that might affect its final value. You can review relationships that depend on forward chaining or backward chaining.
Previous topic More about Constraints rules Next topic Declare Expression form - Completing the Change Tracking tab