Mail script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2024 03:06 AM - edited 06-16-2024 03:13 AM
There is a mail script which populates the variables Requested item number,Description and created on from task table.
This is the mail script which is already present:
var gr = new GlideRecord("task");
gr.get(current.task_id);
template.print("<br>");
template.print("<br>Requesed Item</b> " + "+" + gr.cat_item.getDisplayValue());
template.print("<br>");
template.print("<br>Description</b> " + "+" + gr.short_description);
template.print("<br>");
template.print("<br>Created on</b> " + "+" + gr.sys_created_on);
template.print("<br>");
Now instead of description in i have to populate summary from a catalog item which is sc_req_item table.I have tried to glide the sc_req_item i this script but it is not working.
This is script that i have worked:
var gr = new GlideRecord("task");
gr.get(current.task_id);
template.print("<br>");
template.print("<br><b>Request Item Number:</b> " + gr.number);
template.print("<br>");
var catItem = new GlideRecord("sc_cat_item");
if (catItem.get(gr.cat_item)) {
template.print("<br>");
template.print("<br><b>Summary:</b> " + catItem.u_summary);
template.print("<br>");
}
template.print("<br>Created on</b> " + "+" + gr.sys_created_on);
template.print("<br>");
}).
Please guide.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2024 03:14 AM
Hi there,
The mal script is on the sc_req_item? Than Querying sc_taks with current.task_id is invalid. Task ID is not an existing field. You would need the query which task(s) are related to the sc_req_item, which can be one or more.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2024 09:00 AM
By changing from task table to sc_req_item by making some small changes in the script worked
Thanks!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2024 03:15 AM - edited 06-16-2024 03:16 AM
Seeing your script I assume its only one SC Task?
Something like this might work:
var gr = new GlideRecord("sc_task");
gr.addQuery('request_item', current.getUniqueValue());
gr.setLimit(1);
gr._query();
if(gr._next()) {
// your code
}
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2024 06:19 AM
You can do with a DOT walking
From Task
task.request_item.cat_item.short_description
From RITM
request_item.cat_item.short_description
Thanks,
Narsing