Printing variables value of a variable set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2020 07:01 AM
Hi All
I am trying to print a variable (Short Description) which is part of variable set in a catalog item. But i am not able to print the value under short description variable of the variable set by the notification email script in notifications. Please find below the code for reference and guide me-
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sys_id);
gr.query();
while(gr.next()) {
template.print(gr.number + ": " + gr.cat_item.getDisplayValue() + "<br />");
template.print("Request Title "+ ": " + gr.u_request_title.getDisplayValue() + "<br />");
template.print("Short Description "+ ": " + variables.Short_Description.getDisplayValue() + "<br />");
template.print("Abc" + variables.Short_Description);
}
Variable Sets Variable :-
Notification:-
Regards,
Evan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2020 07:15 AM
Hi,
update as below
you missed gr object
also gr object and short_description field name
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sys_id);
gr.query();
while(gr.next()) {
template.print(gr.number + ": " + gr.cat_item.getDisplayValue() + "<br />");
template.print("Request Title "+ ": " + gr.u_request_title.getDisplayValue() + "<br />");
template.print("Short Description "+ ": " + gr.variables.Short_Description.getDisplayValue() + "<br />");
template.print("Abc" + gr.short_description); // this would print RITM short description
}
Regards
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
10-12-2020 07:34 AM
Hi update as below
make lower-case s and d in short description
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sys_id);
gr.query();
while(gr.next()) {
template.print(gr.number + ": " + gr.cat_item.getDisplayValue() + "<br />");
template.print("Request Title "+ ": " + gr.u_request_title.getDisplayValue() + "<br />");
template.print("Short Description "+ ": " + gr.variables.short_description.getDisplayValue() + "<br />");
template.print("Abc" + gr.variables.short_description); // gr.variables
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2020 07:54 AM
Use below code
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sys_id);
gr.query();
while(gr.next()) {
template.print(gr.number + ": " + gr.cat_item.getDisplayValue() + "<br />");
template.print("Request Title "+ ": " + gr.u_request_title.getDisplayValue() + "<br />");
template.print("Short Description "+ ": " + variables.Short_Description.getDisplayValue() + "<br />");
template.print("Abc" + gr.variables.short_description); // make sure that you give correct column name for short description
}
Regards,
Sachin