- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2023 11:36 AM - edited 06-14-2023 12:42 PM
Hi
I am trying to hide/remove some of the categories and some of the subcategories from the Report an Issue RP on Service Portal view.
I have used on load catalog client script to hide some categories as follows and it worked
g_form.removeOption('category', 'Linux', 'Linux');
g_form.removeOption('category', 'Oracle', 'Oracle');
g_form.removeOption('category', 'Schedule Tasks', 'Schedule Tasks');
g_form.removeOption('category', 'Solaris', 'Solaris');
g_form.removeOption('category', 'vmware', 'vmware');
g_form.removeOption('category', 'User Email', 'User Email');
similarly I have tried both on load and on change to hide/remove some categories under Network Catalog but not working ( I know it is due to dependent value but how to overcome it)
var category = g_form.getValue('category');
if (category == 'network'){
g_form.removeOption('subcategory', 'WAN', 'WAN');
g_form.removeOption('subcategory', 'LAN', 'LAN');
g_form.removeOption('subcategory', 'IP Address', 'IP Address');
}
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 05:14 AM - edited 06-15-2023 05:15 AM
Hi Sid,
Created a script include with the filter of choices we need and added this to Subcategory Reference Qualifier.
Now its working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2023 09:41 PM - edited 06-14-2023 09:42 PM
Hi @Rahul Raja Sami I suggest you to use g_form.clearOptions('field_name'); to clear all the choices.
This way they're all removed in one shot and you simply populate only what you need.
g_form.addOption(<fieldName>, <choiceValue>, <choiceLabel>, <targetIndex>);
Refer this URL https://servicenowguru.com/scripting/client-scripts-scripting/removing-disabling-choice-list-options...
your code look like this modify accordingly
var category = g_form.getValue('category');
if (category == 'network'){
g_form.clearOptions('subcategory');
g_form.addOption('field name', 'choice value')
Add all your choices.......
}
This way, you're adding or removing choices from the select-box dynamically based category.
Please don't forget mark reply as Helpful/Correct, if applicable.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 02:33 AM - edited 06-15-2023 02:47 AM
Hi Sid
i have tried as you said but I see no difference here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 02:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 02:53 AM
Although I have tried to clear all the options, but it seems like no option is cleared.
As you can see I am trying to removed the subcategories under Network Category of Report an Issue RP on Service Portal view.