if category is none hide the subcategory field using client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2022 03:53 AM
hii all,
please can anyone answer this question?
I have this question if category value is none hide the subcategory field using client script.
please help me out form this.
thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2022 04:12 AM
Hi,
Please try below onChange client script on Category field
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (newValue === '') {
g_form.setDisplay('subcategory', false);
g_form.clearValue('subcategory');
return;
}
g_form.setDisplay('subcategory', true);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2022 04:51 PM
Hi Aparna,
It might be worth to give a try to UI policies.
You can set a ui policy triggered when category is not empty, that will have an associated ui policy action to set the subcategory field visible (and possibly mandatory).
If you check the flag "reverse if false" it will hide automatically the subcategory field. I consider this easier to implement and to maintain compared with the client script.
Give it a try!! Hope it helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2023 02:04 AM
Hi Cruz
What to do if we don't want sub category field to display if the selected category value has no dependent options in subcategory?