- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 08:40 AM
Can anyone assist me with getting the fields to display correctly for non-text fields? It looks like it will display correctly only if the field is text but if it's a reference field or a drop down it's not pulling the displayed value for the variable.
For example (screenshot below)... the Manager/Department/Work Location variable is a lookup from the associates tables. The output is the sys_id of the selected manager/dept/location and not their display name.
template.print("Requested items: <br>");
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sys_id);
gr.query();
while(gr.next()) {
var stage = gr.stage.getDisplayValue();
if (JSUtil.nil(stage))
stage = gr.stage.getChoiceValue();
template.print(gr.number + ": " + gr.cat_item.getDisplayValue() + ", Stage: " + stage + "<br>");
// Retrieve and print variables for each requested item
var variables = new GlideRecord('sc_item_option_mtom');
variables.addQuery('request_item', gr.sys_id);
variables.orderBy("sc_item_option.order");
variables.query();
while(variables.next()) {
var question = variables.sc_item_option.item_option_new.getDisplayValue();
var answer = variables.sc_item_option.value.getDisplayValue();
template.print(question + ": " + answer + "<br>");
}
template.print("<br>"); // Adds a space between items for better readability
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 12:29 AM
Thanks Roberto,
The two questions are slightly different, the one from the email screenshot being "Select computer profile from the dropdown" and the one in the latest screenshot being "Select a computer profile" - Perhaps one is a flow/workflow variable rather than on the actual item?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 12:29 AM
Thanks Roberto,
The two questions are slightly different, the one from the email screenshot being "Select computer profile from the dropdown" and the one in the latest screenshot being "Select a computer profile" - Perhaps one is a flow/workflow variable rather than on the actual item?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 07:56 AM
I completely missed creating the matching variables on the catalog item from the order guide. Thank you for all of your assistance!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 09:06 AM
Hi Roberto,
Try below something as below, not tested but with should be aligned to this logic
template.print("Requested items: <br>");
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sys_id);
gr.query();
while(gr.next()) {
var stage = gr.stage.getDisplayValue();
if (JSUtil.nil(stage))
stage = gr.stage.getChoiceValue();
template.print(gr.number + ": " + gr.cat_item.getDisplayValue() + ", Stage: " + stage + "<br>");
// Retrieve and print variables for each requested item
var variables = new GlideRecord('sc_item_option_mtom');
variables.addQuery('request_item', gr.sys_id);
variables.orderBy("sc_item_option.order");
variables.query();
while(variables.next()) {
if(variables.sc_item_option.item_option_new.type=='8')//if reference field
{
var question = variables.sc_item_option.item_option_new.getDisplayValue();
var answer = getDisplayNames(variables.sc_item_option.value.getDisplayValue());
template.print(question + ": " + answer + "<br>");
}
else
{
var question = variables.sc_item_option.item_option_new.getDisplayValue();
var answer = variables.sc_item_option.value.getDisplayValue();
template.print(question + ": " + answer + "<br>");
}
template.print("<br>"); // Adds a space between items for better readability
}
}
function getDisplayNames(sysidofrecord)
{
var rec = new GlideRecord('sys_user');
if(rec.get(sys_id)) {
return rec.getDisplayValue();
}
}