I want to hide few knowledge categories from the list while creating knowledge article
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2025 08:25 AM
We have introduced new field named 'Secure Category' which is of type 'true/false' and if the top category is marked as secured means true then while creating the article when we click on the reference icon to select categories then the one which was marked as secured and its sub-categories should not be visible there for us to select.
I checked the dictionary of this field and found it is calling an OOB script include in reference qualifier section.
I extended the OOB script include in a custom one and added few checks to exclude secured categories and updated in reference qualifier section of dictionary but I believe the script include itself is not getting called.
Below is the code for extended script include:
var ExtendedGlobalKnowledgeUtil = Class.create();
ExtendedGlobalKnowledgeUtil.prototype = Object.extendsObject(GlobalKnowledgeUtilSNC, {
getRefQualCategoryIdsForKB: function(kbKnowledgeBaseId) {
var ids = this.getCategoryIdsForKB(kbKnowledgeBaseId);
var validIds = [];
for (var i = 0; i < ids.length; i++) {
if (!this.isCategorySecured(ids[i])) {
validIds.push(ids[i]);
}
}
return validIds.length > 0 ? 'sys_idIN' + validIds.join(',') : '';
},
isCategorySecured: function(categoryId) {
var categoryGR = new GlideRecord('kb_category');
if (categoryGR.get(categoryId)) {
return categoryGR.u_secure_category == true;
}else{
return false; // Treat as not secured if not found
}
},
type: 'ExtendedGlobalKnowledgeUtil'
});
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2025 08:59 AM - edited ‎04-24-2025 09:04 AM
Hello @nikitajos04 ,
Here are some thoughts on this:
Even if you can make your reference qualifier Script Include work as per your requirements, it would only apply when users type in the Category name. It won't apply to the popup that shows up when they click the magnifying glass icon.
That popup is defined in UI Macro "kb_category_reference_lookup", which itself uses UI Page "kb_categories_dialog", and that one is using Script Include "SNC.KnowledgeHelper" to retrieve the categories.
But Script Includes starting with "SNC" are not visible to customers, so you won't be able to change it or even figure out what it does. So you would have to customize the UI Page and figure out your own script to retrieve the categories in the expected way.
In the face of so many obstacles, maybe you can look into a different approach of using a "Query" Business Rule instead. It would basically check if the current user is authorized to see the "Secure Categories" (through a role or other conditions), and if they are not authorized it would do something like this:
current.addQuery('u_secure_category', 'false');
That will hide the secure categories both in the reference field and the popup, without any customization. I have verified this on my end.
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2025 03:01 AM
Hello @Robert H
I tried the solution you suggested and it is working as expected.
Thank you.
Regards,
Nikita Joshi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2025 03:26 AM
Hello @nikitajos04 ,
Thanks for the feedback, glad to hear it helped. You might want to mark your question as answered then.
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2025 07:34 PM
Hello @Robert H ,
Instead of using query business rule, can we get this solution using ui policy or acl?
Thanks