- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 05:53 AM
I am not sure why ServiceNow doesn't have an option to add users to the CC instead of scripting it out but i need help
I have a List Collector on my form where users can add more than one person to the CC of the email that gets sent out
what i am having issues is, to get all the user added to the CC. i know how to add one using the email scripts using a Single line text variable but i need to now how to script it for a List collector.
email.addAddress("cc", current.variables.ccemail.email, ccemail);
i have look at options like putting it into an Array and using a For loop in the script but it doesnt seem to work
Please Help..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2024 06:34 AM
i got the script to work now with this alternation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 06:39 AM
i tried this and doesnt work
email.addAddress("cc", current.variables.ccemail.email, ccemail);
var addAllEmails = [];
var addALLNames = [];
while (next()) {
addAllEmails.push(current.variables.prepared_by.email.toString(), current.variables.ccemail.email.toString())
addALLNames.push(prepared_by.toString(), ccemail.toString())
}
for (var i = 0; i < addAllEmails.length; i++) {
email.addAddress("cc", addALLEmails[i], addALLNames[i]);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 05:08 AM
Any suggestions on how i can proceed with this script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 05:35 AM - edited 02-05-2024 05:36 AM
Hello @Peter Williams ,
I am not sure how you are passing your data but this should work:
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var users = new GlideRecord('sys_user');
users.addQuery('sys_id', "IN", current.variables.<all user to include incc>);
users.query();
while (users.next()) {
email.addAddress("cc",users.email, users.name );
}
})(current, template, email, email_action, event);
this is assuming you have all the users to be included in the notification cc in one variable.Hope that this helps you!
If the provided information answers your question, please consider marking it as Helpful and Accepting the Solution so other community users can find it faster.
All the Best,
Stefan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 11:04 AM
sorry to say but it didnt work