set the email address in the variable set as the CC of the notification email.

Community Alums
Not applicable

Prepare the multi-row 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 do I script the Email?

1 ACCEPTED SOLUTION

Anand Kumar P
Giga Patron
Giga Patron

Hi @Community Alums ,

You can use below script to get varibles in MVRS

 

 

var mrvs = current.variables.mrvsVariableName; // give here name of mrvs
var arr = [];
var parser = JSON.parse(mrvs);
for(var i=0;i<parser.length;i++){
 var user = new GlideRecord("sys_user");
   user.addQuery("sys_id", parser[i]);
   user.addQuery("email","!=","");
   user.query(); 
   while(user.next()){
arr.push(user.email.toString()); // give here name of email variable
      email.addAddress("cc", arr, user.getDisplayValue());}}
	
}

 

 

Use the above logic in mail script and call it in your Notification using ${mail_sctipt:MailscriptName}
Mark it helpful and solution proposed if it serves your purpose.

Thanks,

Anand

View solution in original post

3 REPLIES 3

Anand Kumar P
Giga Patron
Giga Patron

Hi @Community Alums ,

You can use below script to get varibles in MVRS

 

 

var mrvs = current.variables.mrvsVariableName; // give here name of mrvs
var arr = [];
var parser = JSON.parse(mrvs);
for(var i=0;i<parser.length;i++){
 var user = new GlideRecord("sys_user");
   user.addQuery("sys_id", parser[i]);
   user.addQuery("email","!=","");
   user.query(); 
   while(user.next()){
arr.push(user.email.toString()); // give here name of email variable
      email.addAddress("cc", arr, user.getDisplayValue());}}
	
}

 

 

Use the above logic in mail script and call it in your Notification using ${mail_sctipt:MailscriptName}
Mark it helpful and solution proposed if it serves your purpose.

Thanks,

Anand

Community Alums
Not applicable

I tried to create the script you gave me, but the CC is still empty. Where is the cause and how can I fix it?

Hi @Community Alums,

Put logs check what exactly you are getting in arr variable.

Thanks,

Anand