setReplyTo not working mail in script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2016 07:43 PM
Hi all,
I've created a notification that's triggered on insert of a record to sc_req_item and I've used a Notificaion Email Script to add recipients using the email.setReplyTo function but the notification is not triggering. The notification record itself is OK I think because if I add recipients in the 'Who will receive' tab the notification is triggered. But, I can't use that because I need to get the recipients from variables in a catalog item.
Here's the mail script:
email.setReplyTo('john@example.com');
email.setReplyTo('roger@example.com');
email.setReplyTo('johnston@example.com');
email.setReplyTo(current.variables.requestor_email);
email.setReplyTo(current.variables.authorised_by_email);
The script is not working. Any ideas anyone?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2016 07:46 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2016 07:59 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2016 08:07 PM
Hi Jim,
Without a "to" address somewhere, who is the message intended to be sent to?
You said there was no recipients in the "who will receive" and the script has nobody in the send to...
If we're trying to add recipients, then setting the Reply-To may be the wrong strategy. That's where the message goes when the recipient replies. Wouldn't you rather have it come back to the instance rather than a third party?
If the objective is to add the recipients, then why not use the email.addAddress('cc', emailAddress, emailDisplayName);
I'm trying to understand the objective before I start poking at solutions. Thanks.
Section 5: Scripting for Email Notifications - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2016 08:15 PM
It is meant for the addresses in the mail script.
The reason I need to use a mail script is because the addresses are held in variables in a service catalog item. Variables are not available in the list of fields in the 'Who will receive' tab. So a mail script is suggested but it doesn't work.