- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2023 04:22 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2023 04:29 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2023 04:29 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2023 06:56 AM
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