Scheduled JOB Script for the Change Request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2025 04:53 AM
Hi, I'm using the script below, which is not working. Can anyone help me with the script to trigger the notification for the below
A notification has to be triggered 1 workday after the planned end date of a change is reached, and the Change Type is Normal, and the State is Implement

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2025 07:24 AM
Can you tell me what is happening? Is it adding all the Change requests or not ignoring week ends?
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2025 05:37 AM
where are you writing this script?
You can use a daily scheduled job
1) iterate if planned end data is reached/crossed
2) add 1 business day to it
3) then use gs.eventQueueScheduled() to trigger the event on that date/time
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2025 05:41 AM
@Ankur Bawiskar Hi Ankur, I'm using the daily scheduled job with the script. Can you please share the script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2025 05:42 AM
shared below
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2025 05:41 AM
your scheduled job script should be something like this but please enhance
I am sending email to assigned to user
// Scheduled Script Execution: Notify 1 Workday After Planned End Date
var gr = new GlideRecord('change_request');
gr.addQuery('type', 'normal'); // Change Type = Normal
gr.addQuery('state', 'implement'); // State = Implement
gr.addNotNullQuery('end_date'); // Planned end date is set
gr.query();
while (gr.next()) {
var plannedEnd = new GlideDateTime(gr.end_date);
var workdaysAdded = 0;
// Add 1 workday to planned end date, skipping weekends
while (workdaysAdded < 1) {
plannedEnd.addDaysLocalTime(1);
var day = parseInt(plannedEnd.getDayOfWeekLocalTime(), 10); // 1 = Monday, 7 = Sunday
if (day >= 1 && day <= 5) {
workdaysAdded++;
}
}
// If today is equal to or after (>=) the calculated date, trigger the notification
var now = new GlideDateTime();
if (now >= plannedEnd) {
gs.eventQueue('change.implement.overdue', gr, gr.sys_id, gr.assigned_to.email.toString());
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader