Printing variables value of a variable set

Evan2
Kilo Guru

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 :-

find_real_file.png

Notification:-

 

find_real_file.png

Regards,

Evan

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Muhammad Maira1
Kilo Contributor

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

}

sachin_namjoshi
Kilo Patron
Kilo Patron

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