
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2019 03:39 AM
Hi All
I want to fetch the variable input into the Notification(in sc_task table), I tried to achieve it through Email script but its is not fetching.
I wrote my notification sc_task table. & my varaible name is "product_profile" .
(function runMailScript(current, template, email, email_action, event) {
var item = new GlideRecord("sc_task");
item.addQuery("sys_id", current.sys_id);
item.query();
while(item.next()) {
var catalogItem = item.number + ': ' + current.cat_item.getDisplayValue();
var misc = item.variables.product_profile;
template.print(catalogItem + "<br/> Field: " + misc);
}
})(current, template, email, email_action, event);
Regards,
Priya
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2019 04:01 AM
Hi Priya,
I could see the script and some modification to be done; I assume the email notification runs on sc_task table
the item object in your script is of sc_task and sc_task has 1 field request_item which stores RITM information so wherever you have used that I have dot walked upto that level; so you need to go 1 level deeper to get the information
also used if condition since there would be only 1 record with that sys_id in sc_task table
(function runMailScript(current, template, email, email_action, event) {
var item = new GlideRecord("sc_task");
item.addQuery("sys_id", current.sys_id);
item.query();
if(item.next()) {
var catalogItem = item.request_item.number + ': ' + item.request_item.cat_item.getDisplayValue();
var misc = item.request_item.variables.product_profile;
template.print(catalogItem + "<br/> Field: " + misc);
}
})(current, template, email, email_action, event);
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2019 03:46 AM
Hi Pragati,
Check this if not already, it answers the same issue
-Anurag

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2019 03:52 AM
Hi Priya,
Can you print current.sys_id and check if its printing the sc_task sys_id or sc_req_item sys_id. Based on that you can change the query accordingly.
also have you included this script in the notification?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2019 04:01 AM
Hi Priya,
I could see the script and some modification to be done; I assume the email notification runs on sc_task table
the item object in your script is of sc_task and sc_task has 1 field request_item which stores RITM information so wherever you have used that I have dot walked upto that level; so you need to go 1 level deeper to get the information
also used if condition since there would be only 1 record with that sys_id in sc_task table
(function runMailScript(current, template, email, email_action, event) {
var item = new GlideRecord("sc_task");
item.addQuery("sys_id", current.sys_id);
item.query();
if(item.next()) {
var catalogItem = item.request_item.number + ': ' + item.request_item.cat_item.getDisplayValue();
var misc = item.request_item.variables.product_profile;
template.print(catalogItem + "<br/> Field: " + misc);
}
})(current, template, email, email_action, event);
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2019 06:04 AM
Yup, I was doing the same mistake.
I corrected. thanks.
Regards,
Priya