Get display value of reference in service portal widget

asukumar
Kilo Contributor

Hi all,

I have a service portal widget with a reference field in the options schema that points to the Survey Questions table.

I want to get the display value of the question that is selected. options.question just returns the sysid of the question. I already tried options.question.getDisplayValue() and it doesn't work.

Any thoughts?

5 REPLIES 5

Julio Valdez
Giga Contributor

Asukumar, 

I realize this is an old question, but I found answer to this question for myself today. Figured I'd share. 

Instead of getting display value from the options object, you can get the options values through the Widget Options record's widget_parameters field. JSON parse the value and then you'll have displayValues for your reference fields. 

 

// SERVER
(function() {

var params = JSON.parse($sp.getDisplayValue('widget_parameters'));
data.question = params.question.displayValue;


})();