Unable to remove subcategory choice value based on category choice value selection.

mmr
Tera Contributor

We are trying to remove choice value(ex: test) from subcategory when we select a choice value(ex: test1) on Category field. We have tried with onChange client script by using the g_form.removeOption method, but it is not working as there was already a dependent checkbox checked for the subcategory field in the dictionary.

Any suggestion would be helpful for us.

14 REPLIES 14

SanjivMeher
Kilo Patron
Kilo Patron

You can remove the dependent value in sys_choice table record for test subcategory


Please mark this response as correct or helpful if it assisted you with your question.

mmr
Tera Contributor

Here we can not remove dependent value for the field because these should display based on dependency initially. Additionally we want to remove few subcategories based on category selection.

Ct111
Giga Sage

are you doing it on catalog or on normal form like incident.

Because if you have done on normal form like incident then you can configure subcategory dependent values based on category without code just mention it accordingly like 

 

Like SUPPOSE   for category  test1  gives option A, B, C, D in subcategory

then in subcategory you can make category dependent and provide the dependent value as test1 for all options

 

and if it is a catalog then you can do something like this on change of category variable

 

if(cat == 'test1')
{
g_form.clearOptions('sub_cat');
g_form.addOption('sub_cat','', '-- None --');
g_form.addOption('sub_cat','A','A');
g_form.addOption('sub_cat','B','B');
g_form.addOption('sub_cat','C','C');
}

 

Mark my ANSWER as CORRECT n also HELPFUL if it helped.

mmr
Tera Contributor

This is in hr case form, here we can't remove dependent as initially these subcategories should be displayed based on dependency on category. As an addition, we want to remove few choice values when we select specific category. Hope this information helps.

try the script that I gave , in first step it wil clear all options and in next step of addOption it will show only those option which you have added in addOption.

 

Likewise do it for all the options and then check the result.

 

Mark my ANSWER as CORRECT n also HELPFUL if it helped.