Mapping Knowledge Article ownership group based on groups.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
44m ago
Hi Team,
I have a requirement like Below,
1. If KB (Knowledge Base) Can Contribute groups → show only those groups in the Ownership group on the Article.
2.If KB does NOT have Can Contribute groups → show all groups where type = Knowledge in the Ownership group on the Article.
i have written below Script include, and updated the reference qualifier on ownership group.
var GetKBGroups = Class.create();
GetKBGroups.prototype = {
initialize: function() {},
/**
* Returns a dynamic query for Ownership Group field:
* - If KB has "Can Contribute" groups, return those groups.
* - Else, fallback to OOB filter (type contains Knowledge).
* @Param {String} kbSysId - sys_id of the Knowledge Base
* @returns {String} - Query string for reference qualifier
*/
getGroups: function(kbSysId) {
// var groups = []; removed
// If no KB selected, fallback immediately, No KB selected → OOB behavior
if (!kbSysId) {
return 'typeLIKEKnowledge';
}
var groups = []; //ADDED
// Query kb_can_contribute table for groups linked to KB
var gr = new GlideRecord('kb_uc_can_contribute_mtom');
gr.addQuery('kb_knowledge_base', kbSysId);
gr.query();
while (gr.next()) {
if (gr.user_criteria.group) {// Confirm the field path for group
groups.push(gr.user_criteria.group.toString());
}
}
// If groups found, return sys_id filter
if (groups.length > 0) {
return 'sys_idIN' + groups.join(',');
} else {
// Fallback to OOB behavior- Fallback to OOB behavior: show all groups where type contains Knowledge
return 'typeLIKEKnowledge';
}
},
type: 'GetKBGroups'
};
Requirement 2 is not able to achieve , how to fix this.
Regards,
Abhilasha G T
0 REPLIES 0
