- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2023 11:58 PM
Prepare the multi-line variable set (MRVS) "cc_users" in the Service Catalog.
The variable set "cc_users" contains the variable "user_email".
A user sets up multiple email addresses in the "cc_users" form in the Service Catalog.
You want to add these email addresses to the CC of the email notifying the user that the Service Catalog (e.g. the Catalog that creates the RITM) has been processed.
I am trying, but when I look at the actual email notifying users, the CC field remains empty.
How should I write an Email script?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2023 07:15 AM
so basically you have a MRVS and it contains a variable which holds email and you want to include those users in cc of email?
I would suggest you make the user_email as reference variable rather than single line text
If that's correct you need to use email script and something like this, please enhance
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var jsonString = current.variables.cc_users;
var parsedData = JSON.parse(jsonString);
for(var i=0;i<parsedData.length;i++){
email.addAddress("cc", parsedData[i].user_email, parsedData[i].user_email);
}
})(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
‎12-10-2023 07:15 AM
so basically you have a MRVS and it contains a variable which holds email and you want to include those users in cc of email?
I would suggest you make the user_email as reference variable rather than single line text
If that's correct you need to use email script and something like this, please enhance
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var jsonString = current.variables.cc_users;
var parsedData = JSON.parse(jsonString);
for(var i=0;i<parsedData.length;i++){
email.addAddress("cc", parsedData[i].user_email, parsedData[i].user_email);
}
})(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