- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2017 08:29 AM
Hi All,
I have two fields on the form "Category" and "Subcategory". Subcategory is dependent on Category field. Here I'm trying to remove the option from the subcategory based on the option selected in the category field. I have onChange Client script as below. It doesn't seem to be working. Can someone help me on this.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var incident_category = g_form.getValue('category');
if(incident_category == 'Proactive'){
g_form.removeOption('subcategory','system generated');
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2017 08:32 AM
I don't understand why you cannot do this by updating the dependent values in the choice list.
System generated should not be depended on Proactive but instead something else.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2017 08:42 AM
The only downside to this is maintainability. If you ever change the choice list, you will also have to change the hardcoded values in the script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2017 08:58 AM
Hi Akbar,
Please go through the following article by Mark Stranger on ServiceNow Guru.
It was really helpful for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2018 07:32 PM
Also Dependent Logic Executes Later than Client SCript .....so CS is not affecting in any ways.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2024 10:39 AM
Hi Kaleem,
Follow this KB as a workaround
=> https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1641021
Thanks