Prevent a request being raised if the user has either no manager set or the manager is inactive

wiganmichae
Tera Contributor

We have an issue with some user provisioning for the user's manager.  Until we find a fix we want to avoid issues with items auto approving so want to prevent any user who manager field is either empty of the manager in their is inactive to not be able to raise a request.

Ideally one step to do this would be good but we could say to do a scheduled task each day to remove inactive managers from any user's and then have another step for stopping anyone with an empty manager from raising a request.

Any help would be greatly appreciated.

1 ACCEPTED SOLUTION

@wiganmichae 

there is small correction in my script, I updated it above

sharing here as well

gr.addQuery("sys_id", user_id); // it should be sys_id and not sys+id

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

12 REPLIES 12

Hello @wiganmichae ,

 

Please note that if you ever add other "Available for" criteria to your items/categories then this solution might no longer work and users with inactive managers may get access to them again.

A robust solution would be to reverse the logic and use "Not available for", as outlined here.

 

Regards,

Robert

Robert H
Mega Sage

Hello @wiganmichae ,

 

Please create a new User Criteria for Users with inactive or missing managers, with the following script:

 

var grUser = new GlideRecord('sys_user');
grUser.addQuery('sys_id', user_id);
grUser.addQuery('manager.active', 'true');
grUser.query();
answer = !grUser.hasNext();

RobertH_0-1746769234084.png

 

Then add this User Criteria to the Not Available For list of all Catalog Items where this rule shall apply.

 

RobertH_1-1746769276965.png

 

It's important that we use "Not Available For" because it overrides any criteria in the "Available For" list that might still let users without active managers access the Catalog Item.

 

Regards,

Robert

 

Hello @wiganmichae ,

 

Did you get a chance to try this solution, which has been tested prior to posting it?

 

Regards,

Robert