How to hide choices from choice list using client script onchange

swathigangadhar
Tera Expert

How to hide choices from choice list using client script onchange, i want to hide few choices in subcategories when category is changed, i tried using g_form.removeOption('subcategory', '7'); but no luck, how to solve this?

16 REPLIES 16

Hi Harish,



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


    if (isLoading || newValue === '') {


       


          return;


    }


  alert(newValue);


if(newValue=='Application')


  {


  alert('inside if');


  g_form.removeOption('subcategory', 'Policy');


  alert('after');


  }


   


}



Am using this script it is working fine to hide impact urgency and other fields option but not able to hide subcategories.Why? And Policy is subcategory name and value.


Can you share the screen shot what exactly you want to hide? so that I can understand.


Regards
Harish

Category.png


Hi Swathi,



Can you add a screenshot of the choices for Subcategory field under incident. That will confirm the value which you are using for the removeOption() method.



Regards


Ankur


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

s1.pngs2.pngs3.png