how can i add watch list users to cc in the email notifications

venkyyy
Kilo Contributor

hello friends, 

i am trying to send the email notifications to the cc ie the user from the watch list.Could you please help me out 

please provide with details as i am new to scripting.

Thanks,

venkat

 

20 REPLIES 20

venkyyy
Kilo Contributor

Hi Nana,

tq for your response It didn't work

Ashvini Kadus1
Kilo Guru

Hi venkyyy,

 

navigate ->Notification Email script(Under system notification): write down bellow code. 

name: Add_watchlistUser_toCC.

 

if (!current.watch_list.nil()) {

var watcherIds = current.watch_list.split(","); //get watch list addresses and add to cc

var user = new GlideRecord("sys_user"); //get user records

user.addQuery("sys_id", watcherIds);

user.addQuery("notification", 2); //email 

user.addQuery("email", "!=", "");

user.query();

while (user.next()) {

email.addAddress("cc", user.email, user.getDisplayValue()); //add to cc list

}

}

 

 

 

then navigate -> notification(s) of choice ->Under the 'what it contains' tab

under the message HTMl add the below code:

 

${mail_script: Add_watchlistUser_toCC}. //put your notification email script name here.

just for note: do not use any blank spaces between words while giving name to the email script. and also do not put any symbol before $. 

 

 

 

 

Regards,
Ashvini.k
Kindly Hit Helpful, Reply,Mark as Correct Answer if you found useful

 

 

 

 

i have done the same thing as stated above but,couldn't achieve the result 

find_real_file.pngfind_real_file.pngfind_real_file.png

Hey do this way, because <mail_script> tag is not working in notification mail script so i created one template and convert this to mail script, and call it in notification.

 

go to navigation navigate

System policy -> email->template -> new -> in that message HTML write down previous script under <mail_script> your code here </mail_script> 

find_real_file.png

while saving form it will ask you this. select yes. it will auto convert your template to email notification script.

find_real_file.png

and  your template will show like this . copy that name 

find_real_file.png

 

and search that name in notification email script you will get there.

find_real_file.png

now go to the system notification -> notification ->new -> under when to send checked insert and update check boxes. and under what it will contain select template there which you have created. and save form. 

find_real_file.png

 

try it and let me know if have any doubts.

 

hello, it didn't fetch me result.

thanks for giving responses quickly.