Scheduled job not triggering

Arun_Manoj
Mega Sage

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

24 REPLIES 24

@Arun_Manoj 

 

Can you share your scheduled job definition & event registry along with sample output from script background execution ?

 

Thanks,

Bhuvan

I didn't get you. script already shared above

@Arun_Manoj 

 

Can you share screenshots of your scheduled job configuration & event registry. Refer below for sample,

 

Bhuvan_0-1755770209316.pngBhuvan_1-1755770271459.png

Bhuvan_2-1755770308010.png

If this helped to answer your query, please mark it helpful & accept the solution.

 

Thanks,

Bhuvan

@Arun_Manoj 

 

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

Shivambitanwar1
Tera Contributor

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