getValue() is returning label of a choice instead of Value

Yesh
Tera Contributor

Hi all,

I want to get the value of a choice of a field. 

Field Label: Month

Field ID: month

Field Type: Choice

var month = g_form.getValue('month');
g_form.addInfoMessage(month);

By this I am getting the 'January', but I need the value of January i.e., '1'.

How to achieve this?

Thanks,

Yesh

16 REPLIES 16

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

g_form.getValue() will give choice value always

Can you share the screenshot of field configuration?

Regards
Ankur

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

Hi,

 

I am getting label, but i need value of it. Is there any way to get the value of a selected choice?

 

find_real_file.png

 

find_real_file.png

 

Regards,

Yesh

Hi,

what is the field type?

Is it string with choices or choice itself?

regards
Ankur

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

Hi, 

It is choice type only not string type with choices.

Regards,

Yesh