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

Hi,

did you check for any other field on any other table?

does it give label or value?

regards
Ankur

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

Hi,

I have checked with a choice field in another table, it is returning value of the selected choice only. But in the table I am trying retrieve the month value of the selected choice is returning the Lable.

Is there anything I have to change in table dictionary?

Regards,

Yesh 

Issue is not with getValue() but with your field setting somehow. getValue always returns the value of a choice field and not label.

 Can you add a screenshot of the dictionary form the native ui? 

-Anurag

Hi,

then somewhat issue in your field configuration

you didn't share the field configuration screenshot which I asked 1 hr ago

Regards
Ankur

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

@Yesh

Any update on this?

Regards
Ankur

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