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

Ankur Bawiskar
Tera Patron
Tera Patron

@Arun_Manoj 

How did you confirm it's not running?

Did you add logs using gs.info()?

what debugging did you do?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

when i check event registry log not show the any status

Hi @Arun_Manoj ,

 

Is scheduled job active?

 

Ensure you are checking in same environment and check the code is working properly by execute now and log the info if runs successfully. 

 

Thanks,
Bhimashankar H

 

-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!

Please verify the privileges assigned to the 'Runes' user. Alternatively, you can try using the 'System Administrator (admin)' role for access.