getDisplayValue() Returns Blank in Catalog Client Script When Adding Select Box Choices

gdo
Tera Contributor

Hi everyone,

I am trying to dynamically add choices to a Select Box in a Service Catalog item based on the selected Entity. The logic is:

  • If the Entity contains "abc", add two new MacBook choices.
  • I can get the sys_id of the selected Entity using newValue, but when I try getDisplayValue(), it returns blank.

Issues & Questions:

  1. Why is getDisplayValue('entity') returning blank?
  2. Since I only have the sys_id, what’s the best way to get the display value inside a Catalog Client Script?
  3. Is there a better approach to dynamically add choices when "abc" is in the Entity name?

 

1 ACCEPTED SOLUTION

@gdo There is an issue with your code. Use the following.

 

var v = g_form.getDisplayValue("entity");
alert(v);

View solution in original post

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

@gdo 

Is entity variable a reference variable?

If yes then the way how display value works is different in portal and native

here is my blog which talks about the same.

Get Display value of reference variable Service Catalog 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hello,

Yes it is a reference, to the core_company table.
I saw your blog, but when I use :

var v = g_form_getDisplayValue("entity");

alert(v)

 

>> The alert on the portal returns blank. 
I tried every method existing to get the display value. I only get the sys_id with newValue variable

@gdo There is an issue with your code. Use the following.

 

var v = g_form.getDisplayValue("entity");
alert(v);

Veer
Tera Guru

Hello @gdo 

Please use g_form.DisplayBox('reference field name').value;

Please mark this as helpful / accepted solution if it resolves your issue.

Regards

Veer