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 12:03 PM
Hi @Snow-Man
To add your custom logic or to override any method, you can use KBWorkflow Script include( Which is provided to Override out-of-the-box calls for KBWorkflowSNC)
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 08:11 PM
Hi, I tried doing it but it is not working, any help?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 12:53 PM
copy the function you want to change from the KBWorkflowSNC script include to the KBWorkflow script include, and make your change there. As recommend by Voona.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 01:12 PM
What is your use case here? And why do you want to extend the OOTB script Include? If this is just to remove owner approvals, You can just edit the workflow or create a new one and use it in the KBs