Unable to remove subcategory choice value based on category choice value selection.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2019 10:19 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2019 10:35 PM
Hi,
If you are using dependent field then no need to use onchange script
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2019 10:33 PM
Hi Ankur,
If it is not a dependent field, how to clear the sub category value based on category removal. I have created two list collector variable for the category and sub category.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2021 11:02 AM
This is incorrect. You may only want to show a subcategory field to a certain group of users.
He has a perfectly legitimate use case.
https://youtube.com/watch?v=zYi8KhP9SUk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2021 06:28 AM
Hi Ankur,
I have one requirement for which i am facing problem to achieve this, i need to remove certain options from the subcategories on the portal for the incident record producer, below is the script i created but seems not to be working
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var incident_category = g_form.getValue('category');
if(incident_category == 'infra')
{
g_form.removeOption('subcategory', 'provision');
g_form.removeOption('subcategory', 'crm');
}
}
can you please help me why this is not working, is this anything related to the dependent field we are using on record producer which is conflicting?
how can i achieve this?