Question
Morgan Stanley
IN
Last activity: 27 Aug 2019 9:41 EDT
When does a declare trigger exactly gets executed
Scenario 1:
1. When i save a WO1 using Obj-Save, trigger is executed. When i'm manipulating some objects in the trigger should i explicitly add any writenow/commit statements or will they be part of the same commit transaction of the WO1. If yes, suppose in an activity i have update the WO1 and issues commit in the immediate next statement. What happens to he deferred statements in the trigger?
2. Similar is the case with commited save trigger. Will the trigger be executed before the object is comitted to database. If yes, will the commit be deferred till the trigger execution is completed. I mean if declare trigger takes 2 minutes to complete, will the WO comitting be put on hold till then?
***Moderator Edit: Vidyaranjan | Updated Platform Capability***
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Vodafone
IN
Hi Haria,
Thanks for posting your query on PSC.
1. If a declare trigger execution is set as "run on background copy", There will be a parallel process data synchronization and committing the data to DB. In such cases, its recommended not to modify the values. In case if the data is modified obj-save will be throwing an error resulting to inconsistent data.
Ref:https://community.pega.com/sites/default/files/help_v73/procomhelpmain.htm#rule-/rule-declare-/rule-declare-trigger/trigger.htm%3FTocPath%3DReference%7CRule%2520types%7CDeclare%2520Triggers%7C_____3
2. Declare triggers are always executed before the object is committed to the database. If you define Declare Trigger's execution method as Background, then Pega creates new requestor(User's access group) and then executes the Declare Trigger in that requestor. The reason for this option is to consider the performance impact of the application.
Regarding the failures in execution activity, Pega does not have requeue mechanism. You need to code your activity smartly to handle the unknown errors.
-
Cloe Walker Kensho Tsuchihashi
Merkle
GB
Hi Haria,
Please find my response below:
1. When i save a WO1 using Obj-Save, trigger is executed. When i'm manipulating some objects in the trigger should i explicitly add any writenow/commit statements or will they be part of the same commit transaction of the WO1. If yes, suppose in an activity i have update the WO1 and issues commit in the immediate next statement. What happens to he deferred statements in the trigger?
Answer: That's all depend on your Trigger configuration, if you define execution immediately and committed-save, then will trigger the activity post write now/ commite. If you done in background, then that will not impact the stand alone run, will execute in separate requested and will be manage by Pega.
Hi Haria,
Please find my response below:
1. When i save a WO1 using Obj-Save, trigger is executed. When i'm manipulating some objects in the trigger should i explicitly add any writenow/commit statements or will they be part of the same commit transaction of the WO1. If yes, suppose in an activity i have update the WO1 and issues commit in the immediate next statement. What happens to he deferred statements in the trigger?
Answer: That's all depend on your Trigger configuration, if you define execution immediately and committed-save, then will trigger the activity post write now/ commite. If you done in background, then that will not impact the stand alone run, will execute in separate requested and will be manage by Pega.
2. Similar is the case with commited save trigger. Will the trigger be executed before the object is comitted to database. If yes, will the commit be deferred till the trigger execution is completed. I mean if declare trigger takes 2 minutes to complete, will the WO comitting be put on hold till then?
Answer: Committed save will be trigger after the commit happened post any save operation in Pega. So, in this configuration, the WO committing will not wait for trigger execution.
Note: You can see more details in
link.
Hope, was able to help you!
Thank you!
Gopesh
Morgan Stanley
IN
Thanks for the replies.
When i used Committed Save with immediate trigger activity.. Will the committing to database wait till the activity completes?
CollabPartnerz
IN
It commits the data Immediately.
Capgemini Sverige
SE
Hi Haria,
I don't think it will wait till trigger activity execution.
Best way to trace the trigger to completely understand the sequence of events
Merkle
GB
It will commit first, then right after commit immediately the Trigger activity will fire and execute before another other operation.
Morgan Stanley
IN
Seems like the committing happens only after the trigger is executed in both the cases Commit save/deferred save.
I have exposed a integer property in a table.. Set the value in the first step and clicked submit.
In the trigger i have added a wait method with 15sec time.
When i submitted the WO it kept waiting and has not comitted to DB. after the time interval is completed it committed.
Which means till the trigger execution is not complete its not comitting to database.
This is my observation. feel free to counter?
Accenture
IN
Can we have two declare triggers defined for same work class?
Pegasystems Inc.
IN
You can have two declare triggers for same work class