Get Display Value from Choice List

mdidrikson
Kilo Contributor

Hello,

I created a UI Action where I query a table from the CMDB and update data on a form with the results on a Catalog Task page. One of the values I am retrieving is a Choice List and I would like to get the display value and populate on the other page, but it is not working.

Here is the code I am using where rec.operational_status is the retrieved value.




current.u_operational_status.setDisplayValue(rec.operational_status.getDisplayValue());



Is there something I am missing to make this work?

Thanks!

Mark Didrikson

3 REPLIES 3

CapaJC
ServiceNow Employee
ServiceNow Employee

I don't think you're missing anything. Choice List fields don't currently support a setDisplayValue() method that does what you're trying to do. There's just setValue(). I think setDisplayValue for a Choice List will simply end up using setValue instead.

I do not know the reason why getDisplayValue for Choice Lists was enhanced to work as expected and setDisplayValue was not - perhaps had something to do with concerns about internationalization, or perhaps just that the need wasn't there at the time.


CapaJC
ServiceNow Employee
ServiceNow Employee

It might be a pain, but you could probably query the sys_choice table for the name/element/language/label combination you need, get the value that way, and set the value in the choice list.


mdidrikson
Kilo Contributor

Thanks for the responses! I appreciate it!

Mark Didrikson