How to Add CC Approvers in Notification Email for RITM Reminders in ServiceNow

LokeshwarRV
Tera Contributor

Hi ServiceNow Community,

I have a requirement to trigger a notification reminders email to the requester and with all approvers in CC for a specific RITM (Request Item) on day 5 and day 7 . I have created an event in the event registry for the sc_req_item table with the event name approval_reminder.notification. I also created a notification using the sc_req_item table, and set the recipient to requested_for.

However, I am struggling to add the approvers in the CC field of the notification. Below is the script I am using in my Script Include:

var q = new QuestApprovalHelper();
var grApproval = new GlideRecord('sysapproval_approver');
grApproval.addQuery('state', 'requested');
grApproval.addQuery('sysapproval.sys_class_name', 'sc_req_item');
grApproval.addEncodedQuery("sys_created_on>=javascript:gs.dateGenerate('2025-05-24','00:00:00')");
grApproval.query();

var isprocessed = [];
var ccApprovers = [];

while (grApproval.next()) {
var daysSince = q.daysSince(grApproval); // counted using some functionality and it is working
var requestId = grApproval.getValue('sysapproval');

if (daysSince >= 😎 {
// cancelRequest()
} else if (daysSince === 7 || daysSince === 5) {
gs.print(grApproval.getDisplayValue('sysapproval'));
sendRequesterReminder(requestId);
}
}

function sendRequesterReminder(requestId) {
if (!isprocessed.includes(requestId)) {
var ccApprovers = [];
var grApproval = new GlideRecord('sysapproval_approver');
grApproval.addQuery('state', 'requested');
grApproval.addQuery('sysapproval.sys_class_name', 'sc_req_item');
grApproval.addQuery('sysapproval', requestId);
grApproval.query();

while (grApproval.next()) {
ccApprovers.push(grApproval.getValue('approver'));
}
isprocessed.push(requestId);
gs.eventQueue('approval_reminder.notification', requestId, '', ccApprovers.join(','));
}
}
I need guidance on how to properly add the approvers in the CC field of the notification script or someother. Any help or suggestions would be greatly appreciated!

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@LokeshwarRV 

for setting CC you need to use email script and then use this line

email.setAddress('CC', 'emailAddress', 'name');

You are already sending CC users in event parm2 so use this

(function runMailScript(current, template, email, email_action, event) {

    // Add your code here
    var ccUsers = event.parm2.toString();
    var gr = new GlideRecord("sys_user");
    gr.addQuery("sys_id", "IN", ccUsers);
    gr.query();
    while (gr.next()) {
        email.addAddress('cc', gr.getValue('email'), gr.getDisplayValue());
    }

})(current, template, email, email_action, event);

you can include email script in your email body using this syntax

${mail_script:mailScriptName}

check this for further help

Notification Email Scripts 

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

Hi  

Ankur Bawiskar Thanks for the Replay
can you help me to write the email script according to the below function
var q = new QuestApprovalHelper();
var grApproval = new GlideRecord('sysapproval_approver');
grApproval.addQuery('state', 'requested');
grApproval.addEncodedQuery("sys_created_on>=javascript:gs.dateGenerate('2025-05-24','00:00:00')");
grApproval.query();
var isprocessed = [];
while (grApproval.next()) {
    var daysSince = q.daysSince(grApproval);
    var requestId = grApproval.getValue('sysapproval');
    if (daysSince >= 8) {
        // cancelRequest()
    } else if (daysSince === 7 || daysSince === 6) {
        sendReminder(requestId);
    }
}

function sendReminder(reqId) {
    if (!isprocessed.includes(reqId)) {
        var reqItemGr = new GlideRecord("sc_req_item");
        if (reqItemGr.get(reqId)) {
            gs.print(reqItemGr.getValue('number'));
            var email = new GlideEmailOutbound();
            email.addAddress('to', reqItemGr.requested_for.email, reqItemGr.requested_for.name);
            var grApprovers = new GlideRecord('sysapproval_approver');
            grApprovers.addQuery('sysapproval', reqId);
            grApprovers.query();
            while (grApprovers.next()) {
                email.addAddress('cc', grApprovers.approver.email, grApprovers.approver.name);
            }
             gs.eventQueue('approval_reminder.notification', reqItemGr, email);
        }
        isprocessed.push(reqId); // Add request ID to the processed list
    }
}

@LokeshwarRV 

Sorry but I already answered your original question considering you are sending cc users in eventQueue

Did you try that?

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

@LokeshwarRV 

Hope you are doing good.

Did my reply answer your question?

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