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 09:26 AM
One other thing to keep in mind that some people miss. Client Catalog Scripts require UI Type = ALL to work in the Service Portal. If you have it setup for desktop only, it won't execute on the service portal. I suspect you probably have it on all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2017 10:35 PM
Thanks for your response.
I am keeping it as "Both" only.
And I have tried the Scripts which you have shared.
But still facing the same issue.
Regards,
Anna.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2017 06:02 AM
Hi Anna,
Can you share a screenshot of your form?
Do you have the Choice as Drop down with --None-- selected in the variables you are using?
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2017 07:37 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2017 07:41 AM
Sorry. The form where you dont see -None-
Please mark this response as correct or helpful if it assisted you with your question.