User criteria to allow only users under specific manager
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 01:23 PM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 02:06 PM
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;
}