How to add the user in TO of the email notification?

sri83
Tera Guru

Hi Team,

 

I have created the notification based on the record insert and update but add in user TO list we will push the email id based on the user ID .The user ID is string field in custom table.

 

We need to take the user ID and query to the user table how to achieve this please suggest 

3 REPLIES 3

SoniaShridhar13
Giga Guru

Hi @sri83  You can refer to https://tech.forums.softwareag.com/t/servicenow-email-notification/237436 

 

Please mark it helpful if it helps...

 

Thanks,

Sonia

Ankur Bawiskar
Tera Patron
Tera Patron

@sri83 

the only way is to trigger email notification based on event

Use after insert/update BR and trigger the event.

Ensure you give correct BR conditions

I hope you know how to create event, how to link notification with event

Use this script in BR

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var gr = new GlideRecord("sys_user");
	gr.addQuery("user_name", current.u_user_id);
	gr.query();
	if (gr.next()) {
		gs.eventQueue('event_name', current, gr.email.toString());
	}

})(current, previous);

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

@sri83 

Thank you for marking my response as helpful.

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