extending an OOB script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 10:43 AM
Hello guys,
There is an OOTB script include with getapprovers function.
getApprovers: function(knowledgeGR) {
if (this.isVersioningInstalled() && gs.getProperty("glide.knowman.ownership_group.enabled",'false') +'' == 'true') {
var users = new KBOwnershipGroup().getOwnershipGroupMembers(knowledgeGR);
if (gs.getProperty("glide.knowman.ownership_group.allow_self_approval", 'true') == 'false') {
var author = (knowledgeGR.revised_by && knowledgeGR.revised_by != '') ? knowledgeGR.getValue("revised_by") : knowledgeGR.getValue("author");
if (users.indexOf(author) != -1)
users.splice(users.indexOf(author), 1);
}
if (users.length > 0) {
users = this._filterInactiveUsers(users.toString());
if (!gs.nil(users))
return users;
}
}
var kbOwner = knowledgeGR.kb_knowledge_base.owner;
var kbManagers = knowledgeGR.kb_knowledge_base.kb_managers;
var approvers = '';
if (kbOwner.active) {
//Approval activity will handle any trailing comma, if there are no managers.
approvers = kbOwner + ",";
}
approvers = approvers + this._filterInactiveUsers(kbManagers);
return approvers;
},
/*
* Internal function used to fetch invalid users and remove them from user list.
*
* @Param users- comma seperated list of user_ids
* @return String-comma seperated list of user_ids
*/
_filterInactiveUsers: function(users) {
if (gs.nil(users)) {
return '';
}
//Fetch for inactive users.
var inactiveUsers = new GlideRecord('sys_user');
inactiveUsers.addQuery("active", "false");
inactiveUsers.addQuery('sys_id', 'IN', users);
inactiveUsers.query();
//Check for any inactiveusers.
if (inactiveUsers.hasNext()) {
var userArray = users.split(",");
while (inactiveUsers.next()) {
var useridx = userArray.indexOf(inactiveUsers.getUniqueValue()+'');
if (useridx != -1)
userArray.splice(useridx, 1);
}
users = userArray.toString();
}
return users;
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 07:49 PM
Yes, I just want to remove the owner approvals, in the workflow, they are calling this scriptinclude for approvals.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 08:13 PM - edited 09-16-2024 08:58 PM
Original:
var kbOwner = knowledgeGR.kb_knowledge_base.owner; var kbManagers = knowledgeGR.kb_knowledge_base.kb_managers; var approvers = ''; if (kbOwner.active) { //Approval activity will handle any trailing comma, if there are no managers. approvers = kbOwner + ","; } approvers = approvers + this._filterInactiveUsers(kbManagers); return approvers;
Modified :
Remove logic related to owners
So last lines should be like
var kbManagers = knowledgeGR.kb_knowledge_base.kb_managers;
return this._filterInactiveUsers(kbManagers);
Also check your other post where I explained the same.
Mark as accepted as solution and helpful it is resolved