add users of a list collector field which is referencing to user table in a email CC

Amit Dey1
Tera Contributor

Hi ,

I have a list collector field in a table , which is referencing to user table , my requirement is to add those users in a email cc , so how can we do this via email scripts or any other ways ?

 

 

Thanking you in advance...

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Amit Dey1 

should be easy task

(function runMailScript(current, template, email, email_action, event) {

	// Add your code here
	var gr = new GlideRecord("sys_user");
	gr.addQuery("sys_id", "IN", current.u_my_field);
	gr.query();
	while (gr.next()) {
		email.addAddress("cc", gr.getValue('email'), gr.getValue('name'));
	}

})(current, template, email, email_action, event);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Amit Dey1 

should be easy task

(function runMailScript(current, template, email, email_action, event) {

	// Add your code here
	var gr = new GlideRecord("sys_user");
	gr.addQuery("sys_id", "IN", current.u_my_field);
	gr.query();
	while (gr.next()) {
		email.addAddress("cc", gr.getValue('email'), gr.getValue('name'));
	}

})(current, template, email, email_action, event);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

It worked Thanks