Client Script to update the Choice List on the Subcategory field based on the Company
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2018 08:35 AM
I have a Category of Software and a list of applications defined in the Subcategory. These are configured via Choice List.
I want to remove one application from the Subcategory list when a specific Company is selected.
I have done something similar via an OnChange Client Script based on the Company field but I can't get this to work. This is the script I have....
The sys_id is the correct sys_id for the Company.
Where am I going wrong?
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2018 03:07 AM
The Subcategory value in question appears for 2 different Category values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2018 03:58 AM
Try below script.
var category = g_form.getValue('category');
if(newValue == '86c1f3193790200044e0bfc8bcbe5d95' && category == 'software') //copy your company sysid
{
g_form.removeOption('subcategory', 'sonata'); //sonata - choiceValue
}
else
{
g_form.addOption('subcategory', 'sonata', 'Sonata'); //fieldName, choiceValue, choiceLabel
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2018 04:42 AM
You have to write one more OnChange Client Script based on the Category.