restrict form to direct and indirect reports of an manager

BijoyDeb
Tera Contributor

Hi All,

We have one catalog item that needs to be visible only to the users who directly/indirectly reports to one of the manager.

How can I use user criteria to fulfil this requirement?

I tried searching on community, but didn't find correct solution.

Please help me with any blog if its there

 

Thanks!

4 REPLIES 4

Anand Kumar P
Giga Patron
Giga Patron

Hi @BijoyDeb ,

 

In User Criteria you have to click on advance checkbox and write script like below.

var managersys_id='32 bit ID'// call this from system proerty specific manager sys_id
var userID=gs.getUser();

var user=new GlideRecord('sys_user');
user.addQuery('sys_id',userID);
user.query();
if(user.next()){
if(user.manager ==managersys_id){
return true;
}

 Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand 

Jim Coyne
Kilo Patron

Not sure what you mean by "directly/indirectly reports to one of the manager" in terms of data in your ServiceNow instance.

 

Are those users part of a unique Group or Department?  If not, you might want to create a new Group for them and setup the User Criteria based on that Group.  The scripting option is not the best way to do it as it needs to be evaluated every time.

@Jim Coyne For example, A is the manager and B reports to A and C reports to B. In that case both B and C should be able to see that catalog item. 
This is upto 3 level

Can you create a Group for them all?  Or are they, and only them, all in the same Department?