Populating catalog item variables on the "Request Opened" email notification

Roberto R
Tera Contributor

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.

 

rrivera_0-1714589150862.png

 

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
}

 

 

 

 

 

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

@Roberto R  change question_text to item_option_new. 

eg:

 

 

var question = variables.sc_item_option.item_option_new.getDisplayValue();

 

Thanks,

Harsh

 

View solution in original post

2 REPLIES 2

Harsh Vardhan
Giga Patron

@Roberto R  change question_text to item_option_new. 

eg:

 

 

var question = variables.sc_item_option.item_option_new.getDisplayValue();

 

Thanks,

Harsh

 

Roberto R
Tera Contributor

@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)?