Restrict few Knowledge bases to 2 roles

Lucky1
Tera Guru

Hello all,

 

I have a requirement where 2 Knowledge bases (kb_knowledge_base) has to be restricted for both Knowledge manager and Knowledge admin. Apart from those 2 Knowledge bases, they should be able to see all others.
But I have created a group, where those 2 knowledge bases can be seen by the group members.

I have modified the existing oob ACL, but it's not working. 
Below is my script:
ACL: kb_knowledge_base -- None
Role: itil
Script:

var kbKnowledge = new KBKnowledgeBase();

// Allow bulk/system updates
if (kbKnowledge.isMultipleKnowledgeUpdate()) {
    answer = true;
}

// Always allow admin (safety)
// Always allow admins
if (gs.hasRole('admin')) {
    answer = true;
}
else {

    var restrictedKBs = [
        '9d9f2ab3c3b50e90f07c3be6050131d0',
        '246cdc43dbf1341015c8e16c0b9619ca'
    ];

    var allowedGroup = '23a619c7c3f07e508c405883e401312a';

    var kbId = current.kb_knowledge_base + "";

    if (restrictedKBs.indexOf(kbId) > -1) {

        if (gs.getUser().isMemberOf(allowedGroup)) {
            gs.log("KB Article Allowed for group");
            answer = true;
        } else {
            gs.log("KB Article Restricted");
            answer = false;
        }

    } else {
        gs.log("KB Article Allowed for all");
        answer = true;
    }
}


But this is not working because when I impersonate the users and check only last log is coming up. that is, KB Article Allowed for all.

 

So, can someone help on this please?

 

 

Regards,

Lucky

 

 

 

10 REPLIES 10

shivakumarpatil
Tera Expert

Hi @Lucky1 ,

Please use user criteria in your Knowledge Base to control visibility or editing articles.
I think for your requirement there's no need to edit OOTB ACL

Dr Atul G- LNG
Tera Patron

hi @Lucky1 

 

Did you try with User criteria on the knowledge base level?

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

Yes Atul and Shiva Kumar,

 

We used user criteria, but it's not working.

 

 

Regards,

Lucky

Do you mean the Knowledge Admin or the Knowledge Manager can’t see the knowledge bases?

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************