Delay Firing of Approval Inserted Event in Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2018 01:08 PM
We have a workflow that is sending out an Approval. The "approval.inserted" event is automatically triggering our default approval notification. However, we are trying to add some custom verbiage to the Comments section of the approval via a "Run Script" action in the workflow. The trick is, in order to write it to the approval, the "Run Script" needs to run AFTER the approval has been created, but BEFORE the notification has been emailed.
We messed around with adding a "Wait For Condition" (wait for "Approval is Requested") and a "Timer" (for 1 or 2 seconds), and it would work sometimes, but not others. More specifically, it would always write the comments to the Approval, but not always in time before the Notification email was sent out (so it was "hit or miss" on whether or not the email had the comments). I then tried removing the timer altogether, but then it wouldn't write the comments to the approval record.
I think what I need to do is to somehow delay/pause the "approval.inserted" event from firing and sending out the email until the comments are written to the approval record. Is there a way I can do that?
Thanks
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2018 01:47 PM
Hi,
You could modify the approval.inserted sysevent trigger code and initiate the sysevent in the workflow after (or via) the run script.
Alternately it’s very easy to leave OOB untouched,
create a new sysevent of your own in the Event registry and then utilize this in your email, triggering it in the workflow.
Regards Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2018 12:56 PM
Still playing around with this. Not sure if we want to do too much customization from the default triggers and events, though maybe there is not any other options. Will hopefully have some updates next week. More to come...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2018 01:07 PM
So, we were playing around with this, and discovered that making a simple change seemed to work for us. We had a "Switch" statement in our "Run Script" action. Apparently, they are pretty slow when compared to "IF/ELSE" statements. We made the change, and it is now running fast enough that our comments are being captured in our notification.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2018 12:30 AM
Hi,
I would be a little concerned regarding the reliability\consistency of any solution where the processing time difference between a switch\if-else statement was the difference between success and failure, perhaps there is an underlying issue that needs to be identified and addressed....
sys_events are processed every 10 seconds (OOB) and so an approval.inserted event may wait anywhere from 0.x microseconds to 9.99x seconds to be processed once it is triggered - (on occasions this could potentially be longer if your instance has a heavy workload and sys_triggers are queued);
It would be very coincidental if multiple test events for approval.inserted were all triggered so close to the beginning of the event process job cycle that the run time of your switch\if-else statement had any impact.
Regards Tony