Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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!

8 REPLIES 8

@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

Anil Nemmikanti
Tera Guru
Tera Guru

Hi @LokeshwarRV ,

You would require an email script which needs to be added in the Notification.

GlideFather
Tera Patron

You can create a schedule job or a flow, that would fire an event and trigger a notification where you can easily set the recipients. 

_____
This reply is 100 % GlideFather and 0 % AI

Community Alums
Not applicable

Hi @LokeshwarRV ,

Sending the Event with CC Approvers

The gs.eventQueue() method takes:

gs.eventQueue(eventName, gr, parm1, parm2)

 

You are already sending the RITM GlideRecord (requestId), and in parm2, you're passing the comma-separated approver sys_ids.

That’s okay, but ServiceNow notifications don’t natively use parm2 as CC. You need to configure your notification to use that list as dynamic CC addresses.

 

2. Modify Notification: Add Dynamic CC Logic

Edit your notification (approval_reminder.notification) and in the "Who will receive" section:

  1. To: Requested for

  2. CC: Set this to “Script”

In the Script field, add

// cc approvers passed in parm2 (comma-separated sys_ids)
if (event.parm2) {
  var users = [];
  var ids = event.parm2.split(',');
  for (var i = 0; i < ids.length; i++) {
    var userGr = new GlideRecord('sys_user');
    if (userGr.get(ids[i])) {
      users.push(userGr.email);
    }
  }
  recipients = users;
}

 

 

Here’s a refined version of your function:

 

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);

    // Get RITM GlideRecord
    var ritmGr = new GlideRecord('sc_req_item');
    if (ritmGr.get(requestId)) {
      gs.eventQueue('approval_reminder.notification', ritmGr, '', ccApprovers.join(','));
    }
  }
}