- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 01:21 PM
I have an email script to send to the creator and an email address. I have the following in the mail script:
Only test@test.com shows up in the CC field on the list view. How can I get both?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 06:48 PM
you need not query sys_user.
use this
email.addAddress("cc", 'test@test.com', 'Change Management');
if (current.opened_by) {
email.addAddress("cc", current.opened_by.email.toString(), current.opened_by.getDisplayValue());
}
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
12-26-2024 05:07 PM - edited 12-26-2024 05:08 PM
Hi @samadam ,
Try below script ,check if user has valid email.
var userEmail = grUser.getValue("email");
if (userEmail) {
email.addAddress("cc", userEmail, grUser.getDisplayValue());
}
If my response helped, please mark it as the accepted solution ✅ and give a thumbs up👍.
Thanks,
Anand

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 06:34 PM
Can you check if this works for you?
email.addAddress("cc", 'test@test.com', 'Change Management');
var created_by = current.getValue("opened_by");
if (created_by) {
var grUser = new GlideRecord("sys_user");
if (grUser.get("sys_id", created_by)) {
var userEmail = grUser.getValue("email");
if (userEmail) {
email.addAddress("cc", userEmail, grUser.getDisplayValue());
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 06:48 PM
you need not query sys_user.
use this
email.addAddress("cc", 'test@test.com', 'Change Management');
if (current.opened_by) {
email.addAddress("cc", current.opened_by.email.toString(), current.opened_by.getDisplayValue());
}
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
12-26-2024 07:16 PM
That worked. Thank you