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

I'll give the addAddress a go.



Thanks for the suggestion.


Does it matter if I don't use the displayName?


Hi Chuck,



I tried with addAddress and still no luck:



find_real_file.png


Chuck,



Here' the objective



A notification needs to be triggered on insert of a record in sc_req_item.



I have two sets of recipients: three addresses that I can hard code into a mail script and two further addresses that need to come from variables in the catalog item.



The mail scrfipt so far looks like this (not taking into account suggestions made here so far):



email.setReplyTo('example@example.com');


email.setReplyTo('example1@example1.com');


email.setReplyTo('example2@example2.com');


email.setReplyTo(current.variables.requestor_email);


email.setReplyTo(current.variables.authorised_by_email);



I've tried using the addAddress method for one of the hard coded addresses and it didn't work.   Also, I'm not sure if I could call in the catalog variables using that method.



Any help with this is much appreciated.   It's turning out to be much harder than anticipated for something I would have thought was quite simple.


Sanoop1
Kilo Expert

Hi Jim,



Try creating email scrip to specify 'Reply to' and then call this email script in you notification



Creating email script:



Script Name - sampleEmailScript



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



email.setFrom(abc@xyz.com);


email.setReplyTo(abc@xyz.com);



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



Calling email script in you notification(add this in the message section of your notification or template):



${mail_script:sampleEmailScript}




P.S: Hit Correct answer/like/helpful as applicable