- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2025 07:31 AM
I have been tasked with adding the 'requested_for' variable as a CC to the approval request notification. This notification uses email template 'change.itil.approve.role'.
I have created an email script 'cc_requested_for' with this code:
This has been added to the email template 'change.itil.approve.role' however the requested for is not being added to the email notification.
How do I fix this?
Thank you,
Rachel
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2025 09:04 AM
do this if you are talking about requested_for variable and not field on RITM
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
if (current.source_table == 'sc_req_item') {
var gr = new GlideRecord("sc_req_item");
gr.addQuery("sys_id", current.sysapproval);
gr.query();
if (gr.next()) {
email.addAddress("cc", gr.variables.requested_for.email.toString(), gr.variables.requested_for.name.toString());
}
}
})(current, template, email, email_action, event);
if you are talking about requested_for field on RITM then use this
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
if (current.source_table == 'sc_req_item') {
var gr = new GlideRecord("sc_req_item");
gr.addQuery("sys_id", current.sysapproval);
gr.query();
if (gr.next()) {
email.addAddress("cc", gr.requested_for.email.toString(), gr.requested_for.name.toString());
}
}
})(current, template, email, email_action, event);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2025 09:41 AM
Thank you so very much for your suggestion. I used the script for 'requested_for' variable. Test emails added the requested_for variable as a CC on the email.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2025 11:09 AM
@Ankur Bawiskar - thank you again for your suggestion as that worked however one caveat - if there are multiple approvers the requested_for is CC'd on each email. Is there a way to script this so that they only receive one copy of the email if there are multiple approvers?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2025 07:57 PM
You can't control it such that it sends only 1 email for all the approval records
since there will be multiple approval records, email will be sent for each and for each email CC will be included.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader