Options
- 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.