Skip to main content

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

Declare Expression rules

Updated on May 31, 2022

Declare Expression rules automatically calculate values based on other values that are available in your application. When you include Declare Expression rules in calculations, you increase automation and efficiently reuse resources.

For example, you can use a Declare Expression rule to automatically calculate a tax amount for an order in an online shop, based on the prices of items that the order includes.

Declare Expression rules use two methods of calculating values: forward chaining and backward chaining. Starting with Pega Platform version 8.3, Pega Platform automatically applies the most suitable calculation method to each business scenario.

Forward chaining

Forward chaining occurs when the target property changes because the input values in the calculation change. Consider a scenario in which a customer creates an order in an online shop by selecting items that sum up to $60. A shopping application calculates the tax value that is 10% of the order amount and updates the target property with the value of $6. When the customer adds another item to the shopping cart, the application adds the price of the new item to the calculation. Consequently, input values change. The application performs forward chaining and updates the target value, which is the tax amount, based on the updated input values.

For example: Consider a scenario in which customers provide width and length of a room to calculate the room area to order a correct number of floor tiles. Each time a customer changes the width or length of the room, the shopping application automatically updates the room area by performing forward chaining.
For example: The following figure shows a shopping order for which an application calculates the tax amount based on the quantity and prices of ordered items. When a customer changes the quantity by adding two items, the total price changes, so the application performs forward chaining to calculate the updated tax amount.
Forward chaining
A sample use of forward chaining for calculating tax value.

Backward chaining

Backward chaining occurs when an application seeks values of input parameters to calculate a target property. For example, in an online shopping application, when a customer provides a code to get a discount on specific items in a shopping order, the application seeks properties that hold prices of the selected items, and then updates the total order amount. In backward chaining, target values remain unchanged if input values change, and the application performs calculation only after receiving a call for a target property.

Backward chaining directly corresponds to the Property-Seek-Value method. The Property-Seek-Value method can access the computational relationships among properties in a Declare Expression rule to identify source values that are needed to compute a missing property value.

For example: Consider a scenario in which a customer wants to fetch a prevailing foreign exchange rate and a tax rate at the time of quotation. The customer needs to access data from an external system. A declare expression that includes backward chaining fetches data from the external system instantly when the customer wants to access the foreign exchange rate and the tax rate.

Backward chaining is also applicable in the following specific scenarios:

  • Some of the fields in the expression are from data pages that are outside of the current page structure. For example, consider a scenario in which you want to sum up values of multiple sales opportunities, but each opportunity is a separate and independent page.
  • A declare expression invokes a function that has no parameter, such as calculateEmployeeCount(). In such cases with no parameter, change tracking does not happen and the system applies backward chaining.

Users are no longer required to explicitly specify forward or backward chaining. Users can switch to legacy expressions if they want to explicitly specify a change tracking method.


Declare Expression rules are instances of the Rule-Declare-Expressions rule types that are part of the Decision category.

Note: Do not confuse Declare Expression rules with simple expressions. Expressions — which contain syntax that includes constants, function calls, operators, and property references — are often applicable in addition to Declare Expression rules.
  • Creating Declare Expression rules

    Create Declare Expression rules to automatically calculate values in your application. Declare Expression rules take advantage of values that exist in your system to calculate values of target properties. As a result, you increase automation of calculations in your application.

  • Defining expressions in Declare Expression rules

    Define how your application calculates target properties by building expressions. When you build expressions, you create relations between properties so that an application can automatically update property values at run time. As a result, you increase the level of automation and flexibly respond to changing circumstances.

  • Specifying pages and classes for a declare expression

    Define pages and classes that store properties to ensure that declare expressions can access these properties to correctly calculate values for your business scenario. As a result, you increase the level of automation in your application because automatic calculations can occur without user intervention.

  • More about Declare Expression rules

    This topic provides additional information about declare expression rules.

  • 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.

  • Viewing the declarative network

    Quickly gain insight into the relationships between declarative properties, which your system calculates automatically based on the value of other properties. By accessing the declarative network you can view and test declarative rules, which reduces processing errors and development effort.

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. is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us