- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2019 12:53 AM
Dear Community members,
Good Day!
Could someone please let me know, how can I access event parameter in email script?
var Details = {"status" : status_code, "error_message" : errorMessage};
Ex. gs.eventQueue('Ticket Created', gr, Details), here Details (parm1) has 2 values as above which I want to pass to my mail script. Could someone please let me know how can I accomplish this?
Best Regards,
Navin
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2019 02:49 AM
Hello Naveen,
Please check out the below Code :
1. First you need to create Json Formatted object as given below:
var Details ={
"status": 'STATUS code you want to pass',
"error_message": 'ErrorMessage you want to pass'
};
var parser = new JSON(); // Creates an instance of the JSON class.
var formattedDetails = parser.encode(Details); // json formatted object
gs.log('JSON object: '+ formattedDetails);
gs.eventQueue('TicketCreated',current,formattedDetails);
2. EMAIL SCRIPT:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Add your code here
var jsonObject=event.parm1;
template.print("Complete Json Object: "+jsonObject+"<br>");
// Parsing JSON object:
var obj = JSON.parse(jsonObject);
template.print('status is: '+ obj.status+"<br>");
template.print("Error message is "+obj.error_message+"<br>");
})(current, template, email, email_action, event);
3. You can call mail script from notification as :
${mail_script:demoscript} // Replace mail script name demoscript with your mail script name
Please mark answer correct if you find it as helpful.
Thanks,
Abhishek Gardade
Abhishek Gardade

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2019 12:55 AM
you have to use here event.parm1
kindly have a look on below thread for sample code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2019 12:59 AM
Hi Harsh,
Thanks for your quick response.
My requirement is, I need to access the event parameter and send values for status and error message in email notification
Could you please assist on it further?
Best Regards,
Navin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2019 02:24 AM
you can try something like below sample code.
var Details = {"status" : "status_code", "error_message" : "errorMessage"};
var res=Details.status.toString();
gs.eventQueue('<event name>',current,res);
to call event parameter in email script i had already suggested in my above reply.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2019 01:02 AM
Hi Navin,
You can pass it through event.parm1.
Please find below link for more details
=====
====
Let me know if that helps.
Regards,
Monika