Inactive Knowledge Base Managers

eastonreedy
Tera Contributor

I am attempting to build a report on the sys_user table for all inactive users that are listed as a 'Knowledge Manager' for all of our Knowledge Bases (basically anyone who has the knowledge or knowledge_manager role). I am having trouble determining which knowledge bases these inactive users are managers on. Also, are there any additional filters on the report I can add to drill down the results? I attempted to build the report on the kb_knowledge_base table the only option I found would be to show the knowledge base owner with the knowledge base name, not the managers. Any suggestions?

1 ACCEPTED SOLUTION

Robert H
Mega Sage

Hello @eastonreedy ,

 

This cannot be achieved with a report because the Managers field on the Knowledge Base record is a list.

But you can run the following background script to get the information:

 

var grKB = new GlideRecord('kb_knowledge_base');
grKB.addQuery('active', 'true');
grKB.addNotNullQuery('kb_managers');
grKB.query();
while (grKB.next()) {
    var grUser = new GlideRecord('sys_user');
    grUser.addQuery('sys_id', 'IN', grKB.getValue('kb_managers'));
    grUser.addQuery('active', 'false');
    grUser.query();
    while (grUser.next()) {
        gs.info(gs.getMessage(
            'Inactive manager {0} found for Knowledge Base {1}',
            [grUser.getDisplayValue(), grKB.getDisplayValue()]));
    }
}

 

Example output:

*** Script: Inactive manager Abel Tuter found for Knowledge Base IT

 

Regards,

Robert

View solution in original post

1 REPLY 1

Robert H
Mega Sage

Hello @eastonreedy ,

 

This cannot be achieved with a report because the Managers field on the Knowledge Base record is a list.

But you can run the following background script to get the information:

 

var grKB = new GlideRecord('kb_knowledge_base');
grKB.addQuery('active', 'true');
grKB.addNotNullQuery('kb_managers');
grKB.query();
while (grKB.next()) {
    var grUser = new GlideRecord('sys_user');
    grUser.addQuery('sys_id', 'IN', grKB.getValue('kb_managers'));
    grUser.addQuery('active', 'false');
    grUser.query();
    while (grUser.next()) {
        gs.info(gs.getMessage(
            'Inactive manager {0} found for Knowledge Base {1}',
            [grUser.getDisplayValue(), grKB.getDisplayValue()]));
    }
}

 

Example output:

*** Script: Inactive manager Abel Tuter found for Knowledge Base IT

 

Regards,

Robert