How to Hide variable dropdown choice from the Catalog item?

Tanmay Karankar
Tera Contributor

We have two identical catalog item in a service portal. We have to Hide one of dropdown choice from one single catalog item, we use below client script but it didn't work. Please provide some relevant solution for hiding the choice. Please find the below client script we have used.

 

For onChange

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

//Type appropriate comment here, and begin script below
g_form.removeOption('variable name', 'option');
}

 

 

For onLoad

 

function onLoad() {
//Type appropriate comment here, and begin script below
g_form.removeOption('variable name', 'option');
}

3 REPLIES 3

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @Tanmay Karankar ,

What exactly the type of variable is it select box ?. If not then change the type of variable to select box and then. try.

if still not working then try

g_sc_form.removeOption('test_var', 'choice_one');

Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

Hi @Gunjan Kiratkar ,

Thank you for replying. But It Still not working.

Hi @Tanmay Karankar ,

 

The script for onload which you have provided is working on my side. Please try below code as well 

function onLoad() {
   //Type appropriate comment here, and begin script below
	//g_form.removeOption('select_month', 'mar');
	if(g_form && g_form.getControl('select_month')) { //replace with your variable backend name
    g_form.removeOption('select_month', 'mar'); ////replace with your variable backend name & Choice value
   }
   
}

 

Example:-

Screenshot 2023-01-19 at 6.23.29 PM.png


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy