User criteria to allow only users under specific manager

Ben42
Tera Contributor

Hello Devs,

 

I want to create a user criteria to restrict knowledge articles to all the users under specific manager 'John'. And I want to do it by script so that it will be dynamic. 

 

How can I do that?

I tried below script but did not work.

 

var usr = new GlideRecord('sys_user');
usr.addEncodedQuery('manager=05ccebc7dba3e340fasd34g5ca961952'); //John.
usr.query();
if (usr.hasNext()) {
    answer = true;
} else {
    answer = false;
}
 
Thanks,
Ben.
1 REPLY 1

nataliya_b
Tera Guru

your script does not check if logged user has this specific manager

 

it shall be like this:

var sysId = user_id;
var usr = new GlideRecord('sys_user');
usr.addEncodedQuery('sys_id'+sysId +'^manager=05ccebc7dba3e340fasd34g5ca961952'); //John.
usr.query();
if (usr.hasNext()) {
    answer = true;
else {
    answer = false;
}