0% found this document useful (0 votes)
54 views3 pages

Declarative Rules Overview in Pega

The document explains the declarative processing in Pega, highlighting its internal declarative engine that uses a Directed Acyclic Graph (DAG) for evaluation. It outlines six types of declarative rules, including Declare Expression, Declare On Change, Declare Trigger, Declare Index, Constraints, and Data Pages, which automate business logic without manual invocation. Additionally, it provides examples and explanations for each rule type, emphasizing their role in enhancing efficiency and maintaining data integrity.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views3 pages

Declarative Rules Overview in Pega

The document explains the declarative processing in Pega, highlighting its internal declarative engine that uses a Directed Acyclic Graph (DAG) for evaluation. It outlines six types of declarative rules, including Declare Expression, Declare On Change, Declare Trigger, Declare Index, Constraints, and Data Pages, which automate business logic without manual invocation. Additionally, it provides examples and explanations for each rule type, emphasizing their role in enhancing efficiency and maintaining data integrity.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DECLARATIVE PROCESSING IN PEGA

Pega has an internal declarative engine that utilizes abstract Java engine libraries for evaluation.
These libraries use a Directed Acyclic Graph (DAG) network to maintain the declarative
structure. The major difference between cyclic and acyclic graphs is that a cyclic graph can have
closed loops, whereas an acyclic graph has no loops.
In Pega we can write a business logic in two ways:
1) Structural processing: when you can create activity, data transform and other rules and
make sure you manually invoke them at the right places.
2) Declarative processing: you can use a set of declarative rules, to automatically compute
some activity rule using the declarative DAG network. Declarative rules can be called
business rules and can be delegated to business users.
Pega platform provides six types of declarative rules to support declarative processing.
➢ Declare expression (Rule-Declare-Expressions rule type)- mainly used to calculate
target properties when the depended properties change.
➢ Declare on change (Rule-Declare-OnChange rule type)- automatically executes an
action when the dependent property changes.
➢ Declare trigger (Rule-Declare-Trigger rule types)- automatically executes activities
or flow when an instance is created, updated or delated.
➢ Declare index (Rule-Declare-Index rule type)- automatically creates and maintain
indexes for embedded properties
➢ Constraints (Rule-Declare-Constraints rule type)- automatically enforce condition
and validation when referred.
➢ Data pages- also declare pages that can automatically load the data when referred.
(I’ve covered various declarative rules in Pega. Stay tuned—we’ll dive deeper into
Data Pages in an upcoming discussion!)
There is no need to call these rules manually.

What is declare expression rule?


It helps to compute a value based on expressions. mainly used to calculate target properties
when the depended properties [Link] comes under decision category.
Declare expression rule can get triggered automatically based on two methods:
➢ Forward chaining: when ever input changes targeted property get changes.

Example: Total price= cost *Quantity, here if the input values changes(cost, quantity) the
total price also changes.
C=A+B
When A or B value changes C get calculated.

➢ Backward chaining: it is exactly opposite to forward chaining. The application performs


calculation only when the targeted property referred.

Linked In: Bobby Sanaboyina


Example: let’s take an example of discount calculation with a coupon code field.
When the coupon code is referred in the field as the target property and the discount can
be calculated based on the products.
C=A+B
When c get referred it uses backward chaining to find and use value of A & B for
calculation .

(It is very rare nowadays that we use backward chaining in the application processing)
We can configure a declare expression can be done in two places.
➢ Manually creating the declare expression.
➢ From case designer data modelling.

What is declare on change?


Declare on change comes under decision category and implements forward chaining. When a
value of specific property changes then it executes an activity.
Example : imagine a shopping cart in a web site, here the condition is if the total cost is greater
than certain value we have to add a free gift this can be archived by using declare on change.

What is declare trigger?


Declare Trigger, also categorized under decision rules, implements forward chaining. It executes
an activity when an instance of a specific class is created, updated, or deleted. This rule is useful
for automatically updating records when specific changes occur.
( it identifies an activity that runs automatically when an instance of a specific class is saved or
deleted, allowing for automated actions based on data changes.)
Example: Imagine you have an order processing system where you need to update the order
status when the payment is received. Instead of manually checking the payment field every time,
you can create a declare trigger that “watches” the payment field. As soon as the payment is
marked as received, the trigger automatically updates the order status to "Completed.".
I’m an EEE student so I compared it with a sensor.
Think of it like a sensor: when something changes (for example, a property value), the trigger
checks if it meets the set condition, and if it does, it “fires” to perform specific tasks like
updating other properties or executing business logic.

What is Declare index?


A Declare Index rule automatically creates and maintains an index for embedded properties,
improving performance when querying large datasets or navigating relationships within the
application. It typically falls under the system administration category.

Linked In: Bobby Sanaboyina


Example: Imagine a library where you need to find a book quickly. Instead of searching each
shelf manually, you use an index to locate it instantly. Similarly, Pega's Declare Index rule
maintains indexes for important data, ensuring efficient searches and lookups.

What is constrain ?
Constraints in Pega are declarative rules used to enforce conditions and validations on property
[Link] comes under decision category. When a property with an associated constraint is
referred to or modified, the rule automatically checks that the data meets the required condition.
This ensures data integrity and prevents invalid data from being stored or processed.
Example: If a rule specifies that Age must be between 18 and 65, every time someone enters an
age, Pega verifies it. If the value is outside the allowed range, an error message appears or the
data is rejected

I hope this guide clarifies Declarative Processing in Pega!

Linked In: Bobby Sanaboyina

Common questions

Powered by AI

Constraints in Pega ensure data integrity by automatically verifying that property values meet pre-defined conditions whenever they are accessed or modified. They function as declarative rules that enforce validation consistently across the application. For example, if an application requires a user's age to be between 18 and 65, the constraint ensures that any input outside this range generates an error message or rejection, thus maintaining data validity and preventing erroneous entries .

Declarative processing in Pega allows for automatic computation and rule enforcement via declarative rules such as declarative expressions, triggers, and constraints. This method uses a Directed Acyclic Graph (DAG) to maintain dependencies and automatically triggers changes when input data changes. In contrast, structural processing requires manual invocation of rules like activities and data transforms at specific points. Businesses might choose declarative processing for efficiency and consistency, as it reduces manual intervention and ensures immediate response to data changes. However, structural processing might be preferred for complex sequences that require precise control over execution order and conditions .

Declare Trigger rules function like sensors by constantly monitoring specific class instances for changes, such as creation, modification, or deletion. They automatically execute predefined activities once the conditions for these changes are met, similar to how a sensor detects environmental changes and initiates a response. For instance, in an order processing system, a trigger can automatically update the order status when payment is received, ensuring timely updates without manual intervention .

The Directed Acyclic Graph (DAG) enhances the declarative engine's functionality by structuring dependencies in a way that avoids cycles, ensuring calculations can be propagated in a predictable, non-recursive manner. This structure allows Pega's declarative engine to automatically manage and execute rules upon data changes without circular dependencies, facilitating efficient decision-making and data integrity within applications .

Forward chaining in Pega's declarative rules works by automatically recalculating dependent properties when input values change. For example, if a total price is calculated as cost multiplied by quantity, changes to cost or quantity automatically update the total price. Backward chaining, conversely, calculates values only when a dependent property is explicitly referred. For instance, if a discount is based on a coupon field, the discount is computed only when that field is checked. Forward chaining allows more dynamic updates, while backward chaining reduces computation by limiting when calculations are triggered .

The 'Declare On Change' rule is beneficial in scenarios where specific actions must be taken immediately upon changes to property values, such as updating a user interface or triggering additional calculations. This rule operates by implementing forward chaining: when a property changes, associated activities are executed automatically, allowing for responsive and dynamic application behavior. An example is adding a free gift to a shopping cart if the total cost exceeds a certain value, thereby enhancing user experience and operational efficiency .

Declare expressions in Pega facilitate dynamic computations by automatically calculating target properties based on expressions whenever dependent properties change, using either forward or backward chaining. These can be manually created, allowing precise control over the conditions and logic, or generated through the case designer, which provides a user-friendly interface for defining these expressions as part of a broader data model or business process, thereby improving efficiency and user accessibility .

Declarative processing rules in Pega contribute to agility in business operations by allowing automatic execution and enforcement of business logic without manual intervention. This automation reduces development time, decreases errors, and enables faster adaptation to changes as rules adjust automatically to new data patterns. In contrast, traditional programming requires explicit coding and testing of every condition and scenario, which increases overhead and slows down response to change .

Using Declare Index in Pega is advantageous because it automatically creates and maintains indexes for embedded properties, enhancing performance during search operations or when navigating relationships within large datasets. This automated indexing reduces the time and computational resources needed for data retrieval, thereby making applications more efficient and responsive, particularly in complex data environments .

Choosing backward chaining over forward chaining in declare expressions implies that calculations are deferred until the dependent property is explicitly referenced, reducing unnecessary computations and potentially improving performance in environments where such references are infrequent. This approach is suitable for applications where certain calculations are only needed conditionally or infrequently. However, it may lead to delayed updates if dependencies are frequently referenced, whereas forward chaining ensures immediate updates with every input change .

You might also like