Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Get TEXT from select box

DanLuevano
Kilo Explorer

Hi,

I have a select box with some options that are shown, but when I select some option I get the value of the selection, not the name for example:

option in the select box # 1 is "Main avenue 133" but value of this selection is "001". I need to get the "Main avenue..." value.

thank you in advance.

Daniel

4 REPLIES 4

benn23
ServiceNow Employee
ServiceNow Employee

Client side (Client Script) you can do something like this... Assuming you are on the incident form and your choice field's name is 'your_choice_field.'

var myVal = gel('incident.your_choice_field');
alert(myVal.options[myVal.selectedIndex].text);

Server side (Business Rule):
var myVal = current.your_choice_field.getDisplayValue()


thank you, that solve my question 🙂


CapaJC
ServiceNow Employee
ServiceNow Employee

Note that relying on either in a multi-language environment is ill-advised 🙂


Brian Lancaster
Kilo Patron

Hello Daniel,


See my post which I just got an answer for.


GetDisplayValue Client Script