We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

getValue from multiple choice variable

SnowDevOps
Giga Guru

Hello Team

I'm trying to write a catalog client script. I have a variable (multiple-choice type) is called mac_or_pc. 1st choice is Mac and 2nd choice is PC. How do I get the value on the 1st choice & 2nd choice? I'm trying to pass values into the script include. But I got stuck on writing catalog client script. Thanks for your help. 

SnowDevOps_0-1713536554455.png

 

Normally, i write something like this below 

g_form.getValue('mac_or_pc');

or should i write something like this below to get the value of the choices:

g_form.getValue('mac_or_pc', mac); 
g_form.getValue('mac_or_pc', pc); 

 

Thanks 

7 REPLIES 7

Ankur Bawiskar
Tera Patron

@SnowDevOps 

if this is the variable name  -> mac_or_pc then

g_form.getValue('mac_or_pc');

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Dhananjay Pawar
Kilo Sage

Hi,

Use g_form.getValue('mac_or_pc');

this will give you the selected choice and you can store same in one variable and can pass to script include.

 

Thanks.

SN_Learn
Kilo Patron

Hi @SnowDevOps ,

 

In order to get the value of it, you have to write the backend name of variable which is of multi choice.

 

g_form.getValue('mac_or_pc');

This should now populate the selected value: Mac/PC

 

If this solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

Hello @SnowDevOps ,

write below line in your client script

g_form.getValue('mac_or_pc');

or use on change client script for multiple choice variable.

Alert(newValue)