None in Catalog Client Script After clearOption()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 08:41 AM
Hi Experts,
I am trying to dynamically get "Subcategory" based on "Category" from incident table using catalog client script for Service Portal.
Every time category changes the subcategory getting populated normally. No issues.
But the issue is that getting --None-- value only by the first time category change.
Please find my script below,
Name: Catalog Client Script
function onChange(control, oldValue, newValue, isLoading) {
if(newValue == ''"){
g_form.clearOptions('subcategory');
g_form.clearOptions('u_subcategory_2');
}
if(newValue == oldValue){
return;
}
g_form.clearOptions('subcategory');
g_form.addOption('subcategory', 'none', '-- None --',0);
g_form.setValue('subcategory', 'none', '-- None --');
var gp = new GlideRecord('sys_choice');
gp.addQuery('name', 'incident');
gp.addQuery('dependent_value', newValue);
gp.addQuery('element', 'subcategory');
gp.addQuery('inactive', 'false');
gp.query(function(gp) {
while(gp.next()){
g_form.addOption('subcategory', gp.value, gp.label,gp.sequence);
}
g_form.addOption('subcategory', 'none', '-- None --',0);
g_form.setValue('subcategory', 'none', '-- None --');
});
}
Please help me to solve the issue.
Thanks in Advance.
Regards,
Anna.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 08:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 08:54 AM
Hi Sanjiv Meher,
Thanks for your response,
Having the dependent fields already.
Getting all dependent values in service portal item but the issue is unable to get -- none-- value.
Regards,
Anna.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 08:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 09:11 AM