passing parameters in a email script

juan casas
Mega Expert

Hello,

I am able to pass a single parameter to the email from a script include doing the following::


var event_data = {};
event_data.to = to;
event_data.cc = cc;
event_data.additional_emails = additional_emails;
event_data.comment = comment;

// param: name of event
// param: obj
// param1: obj containg all data
gs.eventQueue("x_banun_creops.ReplyEvent", gCO, event_data.to, 'PARAM2');


email script::

gs.error("event.parm1.to.toString()");
gs.error( event.parm1 );   // this passess the email correctly

    
email.setReplyTo( event.parm1 );

    

 

 

I know I am passing the correct parameters because when I do gs.error(), I can see the correct values being passed.

but I don't see the notifications 'To' changing.

I would expect to see a value there.

I added the image of my notifcationsfind_real_file.png

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

try this

var event_data = {};
event_data.to = to.toString();
event_data.cc = cc.toString();
event_data.additional_emails = additional_emails.toString();
event_data.comment = comment.toString();

// param: name of event
// param: obj
// param1: obj containg all data
gs.eventQueue("x_banun_creops.ReplyEvent", gCO, JSON.stringify(event_data.to), 'PARAM2');

email script::

var parser = JSON.parse(event.parm1); // parse the json

email.setReplyTo(parser.to); // fetch the value associated to to

regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

try this

var event_data = {};
event_data.to = to.toString();
event_data.cc = cc.toString();
event_data.additional_emails = additional_emails.toString();
event_data.comment = comment.toString();

// param: name of event
// param: obj
// param1: obj containg all data
gs.eventQueue("x_banun_creops.ReplyEvent", gCO, JSON.stringify(event_data.to), 'PARAM2');

email script::

var parser = JSON.parse(event.parm1); // parse the json

email.setReplyTo(parser.to); // fetch the value associated to to

regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader