Email script & Notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 03:15 AM
My requirement is in the notification if i have 5 catalog items in my name all the catalog items name should be populated in the email body notication.
I have created the notification from the sys_user table and it is triggering by using event that is triggering emails as expected but i m not able to populate catalog items name in my email notification.
I have created an email script to retrieve and list the catalog item names and included that script in the notification but it is not working
Email script that i have created:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 03:54 AM
when you use email script you have to print it using template.print()
why are you returning the value?
are you calling some script include and then returning that value?
you can simply use this in email script to print comma separated catalog item names
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var itemArray = [];
var itemRec = new GlideRecord('sc_cat_item');
itemRec.addActiveQuery();
itemRec.addQuery('owner', current.getValue('sys_id'));
itemRec.query();
while (catGr.next()) {
itemArray.push(itemRec.name.toString());
}
template.print('Catalog items are: ' + itemArray.toString());
})(current, template, email, email_action, event);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 08:09 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2025 05:05 AM
Hi ,
My issue is resolved now thank you all for the response. Will post in some time how it got resolved