Remove option and add option is not working

Niharika14
Tera Contributor

Hi all,

 

The requirement here is to remove option L2 support subcategory when the category is Process Knowledge/System Questions and country is other than Korea , Vietnam , Japan, Thailand. I have written an on change catalog client script which works on change of category . But add option and remove option lines are not working though it is going inside the loop. Please help me out in this. Below is the script for the same.

 

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

}

var country_name = g_form.getValue('u_country');
g_form.addInfoMessage(country_name);
g_form.clearOptions('subcategory');

if (country_name != 'KR' && country_name != 'VN' && country_name != 'TH' && country_name != 'JP') {
if (newValue == "Process Knowledge/System Questions") {
g_form.addInfoMessage(country_name);
g_form.addInfoMessage("1");
g_form.removeOption('subcategory', 'L2 Support');
}
} else {
g_form.addOption('subcategory', 'L2 Support', 'L2 Support');
g_form.addInfoMessage('55');
}

}

10 REPLIES 10

Hi Samaksh,

My script is working on change of category , if you are talking about category in script , tried that also but not working.

Hello @Niharika14 

 

Create a script include with the filter of choices you need and add this to Subcategory Reference Qualifier.

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.

 

Regards,

Samaksh

Hi @Samaksh Wani ,

I can't do this otherwise it will create an impact on whole form.

 

Where exactly is your script not working? If it is on catalog tasks, unfortunately this is a long known bug and servicenow still will not update the documentation.

add/removeOption does not work on change catalog tasks, only on the request item

Hi Markus,

It is working on catalog item only.