script actions and notification- execution order
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2020 05:09 AM
HI team
I have to send some reminder notifications to users after predefined timings and then update the Status in my form .
I am driving the notification via events . Question is - What is the best way to update the Status in my form after sending notifications-
- Email notification Scripts or Script action? .
- Does Script action execute after Notification (event based )or the reverse
- In Either of the above - Will using a current.update() cause any recursion?
Thanks
Lakshmi N

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2020 05:21 AM
Hello Lakshmi,
The mail scripts in notification is mainly used either to fetch data that can be used to send out in notification. It shall not be used for any updates.
So have a script action, which listen to the same event and take care of updates in the script action.
Not sure, current.update is possible as you will not have current object anywhere. The object passed to the event shall be used in the script action or get a new gliderecord object for that table and then do the update.
better to add setWorkflow(false) before update so that no associated BRs or WFs trigger on update of the record.
Regarding the order of execution, i assume both run in parallel as they are different modles listening to the same event. If you want the notification to go first and then Script action to execute, then trigger another event in the notification mail script and write script action for that event.
Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2020 08:30 AM
Thanks Asif .
Script action seems to update the Status but i am unable to find any documentation that mentions execution order of script actions against Notifications
Here is my required sequence
Scheduled job looks for records in certain status-->Generate event-->Notification generated by event-->Script action moves record to next Status - I have a current.update in here . Will it cause any recursion

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2020 09:38 AM
Lakshmi,
Create 2 events.
1st notification listens to the event
2nd notification listens to the script action.
Then follow like this
Scheduled job look for records in certain status -> Generate 1st event -> Notification triggers for 1st event -> In notification mail script, trigger the 2nd event -> Script action fires based on 2nd event and update the status.
Also, since this is a scheduled job, it will not cause any recursion as it already loads the records of specific status, so any update later will not affect your scheduled job result set.
Also, during the update of status, add setWorkflow(false) to avoid triggering any associated BRs or workflows.
Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP