email.addAddress() not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2025 07:11 PM
Can anyone tell me why this script does not update the 'copied' field in the email log. The log statement does display the correct email addresses.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I'm encountering the same issue, any update on this one ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
I never got it working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hey @Rachel55 ,
Two things to check:
- Use getValue('field_name') to pass field values instead of accessing them directly
- Use 'cc' in lowercase as recommended by ServiceNow
Find the corrected code snippet below for reference.
(function runMailScript(current, template, email, email_action, event) {
var userGR = new GlideRecord('sys_user');
userGR.addEncodedQuery("email!=NULL");
userGR.setLimit(5);
userGR.query();
while (userGR.next()) {
var emailAddr = userGR.getValue('email');
if (emailAddr) {
gs.log('cc email: ' + emailAddr, 'EmailScript');
email.addAddress("cc", emailAddr, userGR.getValue('name'));
}
}
template.print("Aanchal was here");
})(current, template, email, email_action, event);
Also — to verify if CC is actually being added, don't check the Recipients field on sys_email table. CC and BCC recipients are not shown there. Instead check the Copied field on the same sys_email record — that's where CC addresses will appear.
https://www.servicenow.com/docs/r/platform-administration?topicPivot=platadm-r_ExScptEmlNtfn
Thanks
Aanchal
Please Accept the solution if it assisted you with your question & Mark this response as Helpful.