How to Add CC Approvers in Notification Email for RITM Reminders in ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 01:23 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 01:43 AM
Hi @LokeshwarRV ,
You would require an email script which needs to be added in the Notification.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 01:55 AM
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.
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 09:25 PM
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:
To: Requested for
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(','));
}
}
}