setReplyTo not working mail in script

jimpaige
Giga Contributor

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?

12 REPLIES 12

Chuck Tomasi
Tera Patron

Hi Jim,



What does the outbound message look like? can you copy/paste the header information here? Particularly, I'd like to see the Headers section.



find_real_file.png


These are headers when recipients were added to the 'Who will receive' tab:



find_real_file.png



Sending is currently disabled which may account for the lack of info.  



When the 'Who will receive' list is empty and I reference the script on the mail body, nothing happens.   No notification is triggered.


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


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.