Need help creating an approval reminder email notification that only sends on business days.

Anthony Dargan
Tera Contributor

When a user request a catalog item that requires approval, an initial email is sent to the approver. After the initial email notification:

We're looking to send a daily email reminder when an approval record ( for RITM) is in 'requested' state.

  • Only send on business days

Note: Approval record will auto-reject after seven business days (this functionality already exist in our instance).

 

4 REPLIES 4

Sheldon  Swift
ServiceNow Employee
ServiceNow Employee

Hi @Anthony Dargan - You can run a scheduled job against a schedule (e.g. '8-5 weekdays excluding holidays'). In the job, you would query the Approval [sysapproval_approver] table then fire an event to trigger your reminder notification.

Thank you, do you have an example of what the scheduled job should look like?

You could try something like this:

 

(function() {
   // Define the schedule sys_id (8-5 weekdays excluding holidays)
    var scheduleSysId = '090eecae0a0a0b260077e1dfa71da828';

    // Get today's date
    var today = new GlideDate();

    // Define the schedule and check if today is a business day
    var sched = new GlideSchedule(scheduleSysId);
    if (sched.isInSchedule(today)) {
        // Query the sysapproval_approver table for requested approvals related to RITMs
        var approvalGR = new GlideRecord('sysapproval_approver');
        approvalGR.addQuery('state', 'requested'); // Only approvals that are in the 'requested' state
        approvalGR.addQuery('sysapproval.sys_class_name', 'sc_req_item'); // Only approvals related to RITMs
        approvalGR.query();

        // Process each requested approval and schedule an event for 8 AM
        while (approvalGR.next()) {
            // Calculate the next 8 AM time
            var eventTime = new GlideDateTime();
            eventTime.setDisplayValue(eventTime.getLocalDate() + ' 08:00:00');

            // Queue the event to be triggered at 8 AM
            gs.eventQueueScheduled('sc_req_item.approval.reminder', approvalGR, approvalGR.sys_id, approvalGR.sysapproval, eventTime);

            // Log the action for debugging purposes
            gs.debug('Scheduled event for RITM approval reminder: ' + approvalGR.sys_id + ' at ' + eventTime.getDisplayValue(), 'Daily Approval Reminder');
        }
    } else {
        // Log that today is not a business day according to the schedule
        gs.log('Today is not a business day according to the schedule. No actions taken.', 'Daily Approval Reminder');
    }
})();

 

The assumption is that the scheduled job would run daily at 3 AM, and you would still need to add your event (in this example, 'sc_req_item.approval.reminder') to the event registry, then create a notification that will send when the event is fired.

 

VaranAwesomenow
Mega Sage

I believe with updates to ServiceNow platform and workflow data fabric below would be the approach.

If you want to achieve it using group approval, you can consider leveraging SLAs on sysapproval_group table

VaranAwesomenow_0-1753160587917.png

 

If you want to achieve at a single RITM level then you can use a flow that triggers on RITM record.

If you want to apply this email reminder on RITM approvals in general then go with flow with trigger as schedule and table and query sysapproval_approver records then write notification logic accordingly. Only downside of flow + schedule is it wont take holiday calendar into consideration, which is available using SLAs.