Script to get the value of the select box
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2020 12:04 AM
Hi ,
I have a select box called 'unit of measurement' which has several values in it . My requirement is , if the 'unit of measurement' field has value 'centimeter' which has the numeric value of '30' , then it would perform some actions .
I am not able to get the value for 'unit of measurment' when i am using g_form.getValue('unit_of_measurement');
it shows me some undefined value .
Can anyone tell me what is the correct function i should be using to fetch the value.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2020 12:15 AM
Hi,
Could you please try using something like this:
var value = g_form.getValue('selectboxName'); // For name
var text = g_form.getOption('selectBoxName', value).text; // For value
In server side, you can access it by using producer.variables.selectBoxName.getDisplayValue()
Hope this helps!
Thanks
Archana
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2020 01:41 AM
Will this work for catalog client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2020 01:54 AM
Hi Naresh,
Can you share what is your requirement here?
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
06-15-2020 02:25 AM
Yes this will work for catalog client script