Sending multiple emails got from catalog variables

Varun Sharma
Tera Expert

Hi Experts, 

 

i've multiple variables on catalog items and i need to send them in notification as well. 

i can't send them directly via Notification module, and event can only have two parameters. 

 

can someone guide me how to do it via notification email script, or any other more efficient method? 

please check the snippet of code i was trying to make it work. 

 

 

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

    // Get the list of recipient email addresses from catalog item
    var emailList = ['abc@abc.com', current.variables.test, current.variables.test2, current.variables.test3, current.variables.test4, current.variables.test5, current.variables.test6, current.variables.test7];

    var notification = new GlideEmail();
    notification.setSubject("hellow from the other side");
    notification.setBody("testing if notification actually works");
    for (var i = 0; i < emailList.length; i++) {
        var recipientEmail = emailList[i];
        notification.addRecipient(recipientEmail);
    }
// will the send method work here ? which line of code will trigger the email in notification email script?
    notification.send(); 

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

 

Regards, 


Varun Sharma

1 ACCEPTED SOLUTION

Mohith Devatte
Tera Sage
Tera Sage

Hello @Varun Sharma ,

You can trigger your event when is condition is satisfied .But while sending parameters push all the variable values in an array of JSON's and send the array as the parameter so that you can access multiple variable values .

 

example :

var arr = [ {"variable1_name":"variable_1_values"} ,{"variable2_name":"variable_2_values"}]

gs.eventQueue('your_event_name',gr/current , JSON.stringify(arr),'');

 

in the email script you can catch your parameters like 

var vrls = JSON.parse(event.parm1);

for(var i=0; i<vrls.length; i++)

{

gs.info(vrls[i].variable1_name);

}

 

Hope this helps 

Mark the answer correct if this helps you 

Thanks

View solution in original post

2 REPLIES 2

Mohith Devatte
Tera Sage
Tera Sage

Hello @Varun Sharma ,

You can trigger your event when is condition is satisfied .But while sending parameters push all the variable values in an array of JSON's and send the array as the parameter so that you can access multiple variable values .

 

example :

var arr = [ {"variable1_name":"variable_1_values"} ,{"variable2_name":"variable_2_values"}]

gs.eventQueue('your_event_name',gr/current , JSON.stringify(arr),'');

 

in the email script you can catch your parameters like 

var vrls = JSON.parse(event.parm1);

for(var i=0; i<vrls.length; i++)

{

gs.info(vrls[i].variable1_name);

}

 

Hope this helps 

Mark the answer correct if this helps you 

Thanks

Thank you Mohith for quick response.

 

My event is declared in workflow and i'm not able to edit workflows due to access issues. 

 

That's why i can't send the parameter values using the gs.eventQueue. 

but i can get all the context variables using the Current object.  

if you can think of anyway of sending email via Notification email script , that will be really helpful.

 

Thanks