Control the visibility of knowledge articles to users based on the article templates

madhuv
Tera Contributor

We have a knowledge base for which articles are added using multiple knowledge article custom templates. 

we need to control the visibility of articles based on the templates with which article is created.

Like, X template articles to be visible for ABC group
          Y template articles to be visible for only PQR group etc..

It seems , the user criteria advanced script doesnot support using 'current' which is limiting us here. 

Do you see any alternatives?

1 REPLY 1

Its_Azar
Kilo Sage

Hi there @madhuv 

 

use a read ACL onkb_knowledge table based on:

Article template and User group membership

Eg: kb_knowledge →read ACL (script)

 

(function () {

  // Template sys_ids
  var TEMPLATE_X = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx';
  var TEMPLATE_Y = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyy';

  // Groups
  var ABC_GROUP = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaa';
  var PQR_GROUP = 'pppppppppppppppppppppppppppp';

  // Template X → ABC group
  if (current.kb_template == TEMPLATE_X &&
      gs.getUser().isMemberOf(ABC_GROUP)) {
    return true;
  }

  // Template Y → PQR group
  if (current.kb_template == TEMPLATE_Y &&
      gs.getUser().isMemberOf(PQR_GROUP)) {
    return true;
  }

  return false;

})();
☑️ If this helped, please mark it as Helpful or Accept Solution so others can find the answer too.

Kind Regards,
Azar
Serivenow Rising Star
Developer @ KPMG.