Script to get the value of the select box

Naresh291
Tera Contributor

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

8 REPLIES 8

Archana Singh1
Tera Expert

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

 

Will this work for catalog client script

Hi Naresh,

Can you share what is your requirement here?

Regards
Ankur

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

Yes this will work for catalog client script