Scheduled job not triggering
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
hi,
I'm facing an issue with scheduled job, it is not triggering .
(function() {
var gr = new GlideRecord('sn_grc_task');
gr.addQuery('active', true);
gr.addQuery('state', 'NOT IN', '3,4,7,9');
gr.addQuery('end_date', '!=', '');
gr.query();
var now = new GlideDateTime();
var currentDate = now.getDate().toString(); // e.g., '2025-08-18'
var sevenDaysBefore = new GlideDate();
sevenDaysBefore.addDays(-7);
var sevenDaysBeforeDate = sevenDaysBefore.toString(); // e.g., '2025-08-11'
var sevenDaysAfter = new GlideDate();
sevenDaysAfter.addDays(7);
var sevenDaysAfterDate = sevenDaysAfter.toString(); // e.g., '2025-08-25'
while (gr.next()) {
var endDateStr = gr.getValue('end_date'); // e.g., '2025-08-18 00:00:00'
var dueDateOnly = endDateStr.split(' ')[0]; // extract '2025-08-18'
if (dueDateOnly == sevenDaysBeforeDate || dueDateOnly == currentDate || dueDateOnly == sevenDaysAfterDate) {
var assignedTo = gr.getValue('assigned_to'); // sys_id of assigned user
gs.eventQueue('sn_grc.due.date.overdue', gr, assignedTo, dueDateOnly);
}
}
})();
running daily
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Can you share your scheduled job definition & event registry along with sample output from script background execution ?
Thanks,
Bhuvan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I didn't get you. script already shared above
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Can you share screenshots of your scheduled job configuration & event registry. Refer below for sample,
If this helped to answer your query, please mark it helpful & accept the solution.
Thanks,
Bhuvan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Did you get a chance to review this ?
I hope you appreciate the efforts to build the script and provide you with a solution. If my response helped to answer your query, please mark it helpful & accept the solution.
Thanks,
Bhuvan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
If it runs via background script and not through scheduled job then might be some scope issues. The event, notification and scheduled job should be in same scope.
//Shivambi