- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2017 11:30 PM
Hi
I have email script as follows
<mail_script>
var item = new GlideRecord("sc_req_item");
item.addQuery("request", current.sys_id);
item.query();
while(item.next()) {
var catalogItem = item.number + ': ' + item.cat_item.getDisplayValue();
var misc = item.variable_pool.alt_poc;
template.print(catalogItem + "<br/> Field: " + misc);
}
</mail_script>
I need to call this script in notifications, please help me out how can i do this?? with example or screen shot.
Any help is greatly appreciated (with examples)
--venky
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2017 11:35 PM
Hello Venkatesh
Create mail scripts in System Policy > Email > Notification Email Script->
(function runMailScript(current, template, email, email_action, event) {
var item = new GlideRecord("sc_req_item");
item.addQuery("request", current.sys_id);
item.query();
while(item.next()) {
var catalogItem = item.number + ': ' + item.cat_item.getDisplayValue();
var misc = item.variable_pool.alt_poc;
template.print(catalogItem + "<br/> Field: " + misc);
}
})(current, template, email, email_action, event);
Now you can call the above mail script in email notification(Message HTML) as ${mail_script:script name}
Here replace script name with the exact name of the notification email script you have created in step 1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2023 03:02 AM
Hello Team,
I just make two fields on Catalog with variables Requester name and Item, Here I have to populate both on notification calling email script.
I have created one email script below: email script name :- {custom_catalog_item_variables}
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Get Variables
var requester = current.variables.u_requester_name.getDisplayValue(toString());
var item = current.variables.u_items.toString();
template.print(requester);
template.print(item);
})(current, template, email, email_action, event);
Now on notification I am calling this email script with correct details like : - ${mail_script:custom_catalog_item_variables}
Now if i want to do preview Notification then these above two values showing Undefined. Please help me to resolve this error. attched screenshot with this .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2017 11:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2018 04:14 AM
Hi
I am calling email script ${mail_script:incident_take_me_to_the_incident} in email body ,its not working for Kinsten version.
Help is appreciated..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2017 12:01 AM
If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
If you are viewing this from the community inbox you will not see the correct answer button. If so, please review How to Mark Answers Correct From Inbox View.