How to access event.parm1 in mail script?

upasanamahanta
Mega Contributor

How to access event.parm1 in mail script?

1 ACCEPTED SOLUTION

ghsrikanth
Tera Guru

In the mail script you have to write - if event.parm1 is a JSON string then you can access in the email script like below


var jp = new JSONParser();


event.info = jp.parse(event.parm1);



I have given an example of a way that we follow to pass multiple information in parameters and this can give much more idea for you -


While you are queueing the event, follow this - gs.eventQueue('event', current, parm1, parm2);


1. parm1 contains JSON structure of following format


{


addressedTo : "John",


sendCcList:''abc@123.com",


sendBccList: "123@abc.com"',


}



2. parm2 should have To list of the recipients.



In the email action, check only Event parm 1 cotains recipients check box, uncheck Event parm 2 as recipients check box.


Go to the email scripts tables-


Write a new email script: notification_email_script     //you can put any name and its advisable to separate the words with underscore


var jp = new JSONParser();


event.info = jp.parse(event.parm1);



event.addressedTo = event.info.addressedTo;


for (var i=0;i < event.info.sendCcList.length; i++)


  email.addAddress("cc",event.info.sendCcList[i]);



for (var i=0;i < event.info.sendBccList.length; i++)


  email.addAddress("bcc",event.info.sendBccList[i]);



Go back to the email action -


In the message HTML put the below line at the top-


${mail_script:notification_email_script}




Mark if it is helpful or correct, feedback is appreciated


View solution in original post

1 REPLY 1

ghsrikanth
Tera Guru

In the mail script you have to write - if event.parm1 is a JSON string then you can access in the email script like below


var jp = new JSONParser();


event.info = jp.parse(event.parm1);



I have given an example of a way that we follow to pass multiple information in parameters and this can give much more idea for you -


While you are queueing the event, follow this - gs.eventQueue('event', current, parm1, parm2);


1. parm1 contains JSON structure of following format


{


addressedTo : "John",


sendCcList:''abc@123.com",


sendBccList: "123@abc.com"',


}



2. parm2 should have To list of the recipients.



In the email action, check only Event parm 1 cotains recipients check box, uncheck Event parm 2 as recipients check box.


Go to the email scripts tables-


Write a new email script: notification_email_script     //you can put any name and its advisable to separate the words with underscore


var jp = new JSONParser();


event.info = jp.parse(event.parm1);



event.addressedTo = event.info.addressedTo;


for (var i=0;i < event.info.sendCcList.length; i++)


  email.addAddress("cc",event.info.sendCcList[i]);



for (var i=0;i < event.info.sendBccList.length; i++)


  email.addAddress("bcc",event.info.sendBccList[i]);



Go back to the email action -


In the message HTML put the below line at the top-


${mail_script:notification_email_script}




Mark if it is helpful or correct, feedback is appreciated