Need to show only active knowledge bases and canconrtibute knowledge bases in the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2025 08:37 AM
Hi ,
I have requirement as per that I have created a custom field called "u_knowledge_base" in the kb_submission table which is in open submission module. here in the field I have to show only the knowledge bases which are active and the users who can have access to can contribute.
Bt for me it is showing all the articles who have read and conrtibute access. But for me I have to show the knowledge bases who have canconrtibute access.
is ther any possibility can help me please this is high priority.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2025 11:23 AM
I have configured the same like script include and the reference qualifier what you have provided. I have impersonated one of the user who doesn't have admin role and in one of the knowledge article I gave can contribute as admin when I impersonated user I can see that admin related knowledge base as well.
The same script include I copied except commented the public related notes since I don't want that logic other than that I configured the same.
what I done is in Open submission form, I created a field "knowledge base" and given reference as knowledge base table.
later I created a script include and added reference qualifier what you have provided but it didn't work as expected can you please help me with this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2025 11:32 PM
Hi @prasannasun ,
can you try this code.
var KBUserCriteriaUtils = Class.create();
KBUserCriteriaUtils.prototype = {
initialize: function() {},
// Function to get knowledge bases the user can contribute to.
getContributableKnowledgeBases: function() {
var userRoles = gs.getUser().getRoles();
var kbSysIds = [];
var kbSysIds1 = [];
// Check for user criteria that grant 'can_contribute' access.
var grUserCriteria = new GlideRecord('kb_uc_can_contribute_mtom');
grUserCriteria.addQuery('user_criteria.active', true);
grUserCriteria.query();
while (grUserCriteria.next()) {
kbSysIds.push(grUserCriteria.getValue('user_criteria'));
}
var userMatches = sn_uc.UserCriteriaLoader().userMatches(gs.getUserID(), kbSysIds);
if (userMatches) {
var grKB = new GlideRecord('kb_knowledge_base');
grKB.addActiveQuery();
grKB.addQuery('can_contribute_user_criteria', kbSysIds);
grKB.query();
while (grKB.next()) {
kbSysIds1.push(grKB.getUniqueValue());
}
// }
}
type: 'KBUserCriteriaUtils'
};and try to add few logs as well.
Thanks,
BK
