declarative processing
declarative processing
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.
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.
(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 constrain ?
Constraints in Pega are declarative rules used to enforce conditions and validations on property
values.it 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