The CreatorCon Call for Content is officially open! Get started here.

passing 3 parameters to event ( To, CC, Comment )

juan casas
Mega Expert

Hello experts,

 I want to pass 3 parameters to an event, so that I can send an email.

The functionality is driven by a custom UI page where the user can change the TO, CC, and email body.

 

The issue that I am having is, how to I route all three parameters to the notification?

 

I can only route two parameters at a time.

If I try to pass an object,  how can I select a key-value pair out of it to be included in the cc or to of the email?

 

this is what I am passing to the notification::

// param0: name of event
// param1: obj
// param2: cc
// param3: comment to be in email being send added
gs.eventQueue("x_banun_creops.ReplyEvent", gCO, {
            "to": to,
            "cc": cc
}, comment); 

1 ACCEPTED SOLUTION

Kartik Sethi
Tera Guru

Hi @juan casas 

When you are passing key-values (JSON object) among different scripts then you need to convert it to string in the source script and then parse it to object again in the target script.

So you need to modify your code as provided below:

// param0: name of event
// param1: obj
// param2: cc
// param3: comment to be in email being send added

//This should be in the source script from where you are triggering the event
var obj = {};
obj.to = to;
obj.cc = cc;

gs.eventQueue("x_banun_creops.ReplyEvent", gCO, JSON.stringify(obj), comment);



//------------------------------------------------------------------------------------

//Mail script

var addressObj;

if(event.param1) {
	addressObj = JSON.parse(event.param1);
}

email.setReplyTo(addressObj.to.toString());
//NOTE: If you want to set CC as well then you need to pass display value also
//e.g. email.addAddress("cc",test@example.com,"Test User");

 

Please do the above changes.

 


Please mark my answer as correct if this solves your issues!

If it helped you in any way then please mark helpful!

 

Thanks and regards,

Kartik

View solution in original post

6 REPLIES 6

O Ok. Ankur answered that already please try that.


***Mark Correct or Helpful if it helps.***

Kartik Sethi
Tera Guru

Hi @juan casas 

When you are passing key-values (JSON object) among different scripts then you need to convert it to string in the source script and then parse it to object again in the target script.

So you need to modify your code as provided below:

// param0: name of event
// param1: obj
// param2: cc
// param3: comment to be in email being send added

//This should be in the source script from where you are triggering the event
var obj = {};
obj.to = to;
obj.cc = cc;

gs.eventQueue("x_banun_creops.ReplyEvent", gCO, JSON.stringify(obj), comment);



//------------------------------------------------------------------------------------

//Mail script

var addressObj;

if(event.param1) {
	addressObj = JSON.parse(event.param1);
}

email.setReplyTo(addressObj.to.toString());
//NOTE: If you want to set CC as well then you need to pass display value also
//e.g. email.addAddress("cc",test@example.com,"Test User");

 

Please do the above changes.

 


Please mark my answer as correct if this solves your issues!

If it helped you in any way then please mark helpful!

 

Thanks and regards,

Kartik