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:11 AM
this is one thread i found to iterate choice value by for loop https://community.servicenow.com/community?id=community_question&sys_id=390f0fa1dbdcdbc01dcaf3231f96...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2022 11:41 PM
Hi,
g_form.getValue() will give choice value always
Can you share the screenshot of field configuration?
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-04-2022 11:46 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2022 11:49 PM
Hi,
what is the field type?
Is it string with choices or choice itself?
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-04-2022 11:51 PM
Hi,
It is choice type only not string type with choices.
Regards,
Yesh