Is declare trigger/Declare onchange rule run by an agent? how does it monitor the change in the property value ? Can someone provide more insight on this?
@SantoshAnisetty
Declare Triggers, specifically, are tied to Save and Delete events. When the Pega Engine is instructed to do a Save, Delete, “Committed Save” or “Committed Delete” operation on an instance (like a work item), it seeks all the corresponding Declare Triggers for the Applies To class of that instance, and executes them before returning control to the caller of the Save or Delete operation.
For monitoring changes in property values, you may be more interested in Declare On Change rules. These are fired as the Pega Engine transitions from one Activity step to the next, and detects changes in the properties configured on any matching Declare On Change rules (based on the Applies To class of the pages with modified properties).
@BraamCLSA Thanq Braam
Hi @BraamCLSA ,
Will Declare On Change rule only fired, when there is changes in property value using only Activity rule ?
@naveeng5663
Declare On Change fires regardless* of the rule type which changes the property value, but it does not fire until the current Activity step completes, as that is when the declarative network is examined for changes.
* maybe there are some special exceptions, but that’s the general philosophy
Usually there is an (out of the box) Activity rule that is orchestrating the execution of other rules in your configuration, using methods like Apply-DataTransform, Obj-Validate and Property-Map-DecisionTable.
Take a Data Page of Data Source “Lookup” and with a Response Data Transform, for example. Ultimately, the Pega Engine calls the Activity pxObjOpen to load this Data Page, in which Step 1 is a Java step that orchestrates loading the instance and running the Response Data Transform. The declarative network is not examined for changes the Data Transform may have made to monitored properties until that Java step in the Activity completes.
I often used to get caught out when I configured Step 1 of a Data Transform to change to a monitored property, and assumed that by Step 2 (in the same Data Transform) that the Declare On Change should have fired. It doesn’t fire then, but it would typically fire when the Data Transform invoked by the Activity finishes.
In the circumstances where an Activity is not involved and the Pega Engine is orchestrating your rules directly, it is up to the Engine when it examines the declarative network for changes.
The best way to check for sure in your scenario is to run the Tracer with the “Declare OnChange” event turned on, after which the Tracer will show after what rule event a Declare On Change rule fires following a change to a monitored property.
Please reply back with what you find!