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-09-2025 05:10 AM
please try below script
(function executeRule(current, gsr) {
var targetDate = getPreviousWorkday(); // Get the last working day
var gr = new GlideRecord('change_request');
gr.addQuery('type', 'normal'); // Change Type = Normal
gr.addQuery('state', 'implement'); // State = Implement
gr.addQuery('end_date', '<=', targetDate); // Planned End Date reached (1 workday ago)
gr.query();
while (gr.next()) {
// Trigger event
gs.eventQueue('change.implement.overdue', gr, gr.sys_id, gs.getUserID());
}
// Get the last working day (skip weekends)
function getPreviousWorkday() {
var gdt = new GlideDateTime();
do {
gdt.subtractDays(1);
} while (isWeekend(gdt));
return gdt;
}
// Returns true if the date is Saturday(6) or Sunday(7)
function isWeekend(gdt) {
var day = parseInt(gdt.getDayOfWeekLocalTime(), 10);
return (day === 6 || day === 7);
}
})(current, gsr);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2025 05:31 AM
@Omender Singh the script is not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2025 05:11 AM
Hi,
I think subtractDays is not working properly. Instead use addDays(-1) as below:
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2025 05:32 AM
@palanikumar not working