- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2020 12:40 AM
Hello all, I need some assistance to the following requirement.
I have a record producer on SP, where depending on the category selection, only related subcategories are visible.
For instance, for the category "hardware", only the following subcategories are visible.
However, if I change to another category (for example "software"), all the options are not visible (only the option "--None--" is visible). Then, if I return back to the category "hardware", all the previous options (shown on the first image) are not visible any more as shown below.
I am using a Catalog Client Script (onChange), that gets the value of the field category, and based on that value removes all the unrelated options on the subcategory field. My script looks like this:
Any assistance would be really helpful.
Thank you all in advance.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2020 12:52 AM
Hi,
Try using format as below
g_form.removeOption('variable_name','value','label');
So,
g_form.removeOption('subcategory','11','CPU'); //suppose 11 is value while CPU is label.
In addition, you need to use g_form.addOption() as well. So, for your case suppose
if(cat==8)
{
g_form.removeOption('subcategory','11','CPU');
..
g_form.addOption('subcategory','7'); //choice you want to show
...
}
So, for every .removeOption() you need to use .addOption() to add & make it work independently.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2020 12:52 AM
Hi,
Try using format as below
g_form.removeOption('variable_name','value','label');
So,
g_form.removeOption('subcategory','11','CPU'); //suppose 11 is value while CPU is label.
In addition, you need to use g_form.addOption() as well. So, for your case suppose
if(cat==8)
{
g_form.removeOption('subcategory','11','CPU');
..
g_form.addOption('subcategory','7'); //choice you want to show
...
}
So, for every .removeOption() you need to use .addOption() to add & make it work independently.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2020 01:18 AM
Thank you!! It seems that it works without any issues.
Regards,
Tomas.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2020 01:29 AM
Hi,
While you got the solution, one thing to notice is to remove a option, you need only the fieldname and value. You don't need label.
Ex: g_form.removeOption('subcategory','11');
But For add, you need 3 arguments fieldname, value, label
Ex: g_form.addOption('subcategory','7','Label'); //choice you want to show
Mark the comment as helpful if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2020 01:41 AM
Thank you very much.
It helps, since I am new to SN.
Thanks again for your time.