- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2024 11:49 AM
I am attemping to add the catalog item variables onto the "Request Opened" email notification. Here is what the RITM's output as... the questions appear as "undefined" and any answer which is a reference lookup shows its sys_id value instead of the display value.
Below that screenshot is the code I am using. Any assistance I can get with this would be greatly appreciated.
template.print("Requested items:\n\n");
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 + "\n");
// 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.question_text.getDisplayValue();
var answer = variables.sc_item_option.value.getDisplayValue();
template.print(question + ": " + answer + "\n");
}
template.print("\n"); // Adds a space between items for better readability
}
Solved! Go to Solution.
- Labels:
-
Request Management
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2024 12:18 PM
@Roberto R change question_text to item_option_new.
eg:
var question = variables.sc_item_option.item_option_new.getDisplayValue();
Thanks,
Harsh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2024 12:18 PM
@Roberto R change question_text to item_option_new.
eg:
var question = variables.sc_item_option.item_option_new.getDisplayValue();
Thanks,
Harsh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2024 01:36 PM
@Harsh Vardhan , thank you that fixed the undefined issue in the script. Do you have any idea on the reference fields showing the sys_id instead of the display value (i.e. Manager shows the sys_id and not the actual managers name)?