- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2024 10:46 PM
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;
thanks in advance,
snowman
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2024 10:52 PM
getApprovers: function(knowledgeGR) {
if (this.isVersioningInstalled() && gs.getProperty("glide.knowman.ownership_group.enabled", 'false') === 'true') {
var users = new KBOwnershipGr
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); // Remove author from the list if self-approval is not allowed
}
}
if (users.length > 0) {
users = this._filterInactiveUsers(users.toString()); // Filter out inactive users
if (!gs.nil(users)) {
return users; // Return the filtered list of ownership group members
}
}
}
var kbManagers = knowledgeGR.kb_knowledge_base.kb_managers;
return this._filterInactiveUsers(kbManagers);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2024 11:37 PM - edited 09-15-2024 11:53 PM
@Snow-Man check my above code..it will work for your case. Only last 2lines are enough and remaining should be removed from original script..for kbowner
Also override OOB script include to customize the logic
To override the initialize function in an OOTB script include, you can follow these steps:
Create a new script include that extends the OOTB script include.
In the new script include, define a function with the same name as the initialize function in the OOTB script include.
In the new function, add your custom code.
When you are finished, save the new script include.
When you use the new script include, your custom code will be executed instead of the initialize function in the OOTB script include.
Mark it as accepted as solution and helpful if it resolved
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2024 11:37 PM - edited 09-15-2024 11:38 PM
Thanks for the code, how do we extend/override an ootb script include?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2024 11:48 PM
Hi @Snow-Man
below thread will work :-
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 10:38 PM
Hi @Snow-Man
Look like you are interested in one person answer and its a game which everyone know why you are accepting the answer from a single individual. Like this you can't reach Heights.
All the Best will ask Servicenow moderator team to check on this
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2024 02:28 AM
Hi Ravi,
First of all, I don’t need to explain myself to you, but I still can, because your help has been invaluable.
Excuse me for accepting Mani's solution and not yours. Mani's was way more detailed (step by step of how to achieve it). Since, I am new to it, I needed a detailed version.
Also, I didn't find your link to extend script include much useful.
So, I chose Mani over yours.
Ps. I follow you on YT :), I wouldn't not have done that if I was the one you think I am 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2024 02:38 AM
Hi @Snow-Man
Understood.. maybe its my mistake as I have seen lot of Spam like this.. I am sorry If you feel bad about it.
And Thanks you cleared my POV.
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/