Notifications

39 views

Description

There are recipients set in the notification "Who will receive" tab

The instance has an email script trying to change the recipient list using email_action object with a script similar to next one:

(function runMailScript(current, template, email, email_action, event) {
	var user = new GlideRecord('sys_user');
	user.addEncodedQuery('user_name=' + current.sys_created_by);
	user.query();
	while (user.next()){
	email.addAddress("to", user.email,user.name);
	template.print(user.name);
	email_action.recipient_users += user.sys_id+",";	
	}
})(current, template, email, email_action, event);

The notification preview shows that apparently the recipients was properly set as the code above logic

Release or Environment

All

Cause

EmailOutbound object's addAddress() method, "to" recipients cannot be modified, as per the docs it supports "cc" and "bcc" only.

Using "email_action" - GlideRecord object for the email notification, it is not possible to change the recipients in the email as it is not the EmailOutbound object(actual email)

For more information, please refer to our documentation: Mail script API

Resolution

Use an event based notification

The option "Event parm 1 contains recipient " is available for event based notifications

Pass the recipient in parm1 while creating event from the script/business rule.

For more information about how to create a notification, follow our documentation page Create A Notification

Article Information

Last Updated:2020-07-27 06:26:32
Published:2020-07-27