- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 10:49 PM
How to add owner ship group as approver if knowledge base is known error in the below code
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 05:29 AM - edited 11-21-2023 05:43 AM
Hey @kesavan4
okay now I see what's going on.
//answer = new KBWorkflow().getApprovers(current);
answer = [];
var authorID = current.getValue('author');
var ownershipGroupID = current.getValue('ownership_group');
if (current.kb_knowledge_base.title.toString() === 'Known Error') {
var grMember = new GlideRecord('sys_user_grmember');
grMember.addQuery('group', ownershipGroupID);
grMember.addQuery('user', '!=', authorID);
grMember.addQuery('user.active', true); //active user
grMember.query();
while (grMember.next()) {
answer.push(grMember.getValue('user'));
}
} else {
answer.push('fbd45ee71bc6659408cd9828b04bcbcb');
}
Enjoy!
Remember to consider cloning the approval workflow to do the customization instead of changing directly in the OOTB one.
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 11:22 PM - edited 11-20-2023 11:25 PM
Hi @kesavan4
You can set the answer as the sys_id of the approval group, it should generate approval requests for each member. So we don't need to do the query to the Group Members table.
Sample for your case.
answer = [];
if(current.kb_knowledge_base.title.toString() === 'Known Error'){
answer.push('31a8a8a3dbc38b003724f5b31d961921');
}else{
answer.push('fbd45ee71bc6659408cd9828b04bcbcb');
}
Also just try to avoid hard-coding by defining the system properties to store the record sys_ids.
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 11:30 PM
Hello @Tai Vu the group will be selected from by user while creating. we need to take that group and add it as approver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 11:37 PM - edited 11-20-2023 11:39 PM
Hi @kesavan4
Okay so let replace the sys_id by that field then.
answer = [];
if(current.kb_knowledge_base.title.toString() === 'Known Error'){ //This condition should use the KB sys_id instead of the title
answer.push(current.getValue('u_owning_group'));
}else{
answer.push('fbd45ee71bc6659408cd9828b04bcbcb');
}
Consider when you put this line "answer = new KBWorkflow().getApprovers(current);" into comment. It might impact to the other KB using the OOTB getApprover function.
Cheers,
Tai √u
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 12:02 AM