getValue() is returning label of a choice instead of Value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2022 11:31 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2022 12:20 AM
Hi,
did you check for any other field on any other table?
does it give label or value?
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2022 12:27 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2022 12:37 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2022 12:47 AM
Hi,
then somewhat issue in your field configuration
you didn't share the field configuration screenshot which I asked 1 hr ago
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2022 12:04 AM
Any update on this?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader