Not able to setValue() in a lookup select box

Kevin Paul
Mega Guru

Hi,

I have a client script where I use the value of a variable as a reference to populate rest of the fields. But this is not working when it is a lookup select box. Why is it so? I have added the code here and the outcome.

find_real_file.png

Here intsall_status is a lookup select box in a catalog item. How can I set value in the field?

1 ACCEPTED SOLUTION

It worked, I changed the look up table of the variable from sys_choice to alm_asset.

View solution in original post

10 REPLIES 10

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi @Kevin Paul 

use setDisplayValue instead of setValue.

Let me if this works.

Regards

Alberto

Not working

Ankur Bawiskar
Tera Patron
Tera Patron

@Kevin Paul 

"getReference" will not work on a Lookup Select Box!  It works on "Reference" fields.

It is not recommended to use getReference() in client side

please use GlideAjax and Script Include approach

Regards
Ankur

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

I used it but still no change! I'm trying to populate this field but it is not showing the value which is in the record. The value in the record is "missing" but everytime the catalog item is opened, the field is showing this "consumed" value by default. I have not given any default value in the variable specification too.

find_real_file.png