The Zurich release has arrived! Interested in new features and functionalities? Click here for more

How to check if a user is a manager

karthiknagaramu
Kilo Sage

How to check if a user is a manager considering user table has large number of records.

8 REPLIES 8

Bhargava4
Mega Expert

Hi Karthik,



User record filter with condition like below



find_real_file.png



Thanks,


Ram


Scheuerman1
Mega Expert

Filtering the data is very straight forward (see previous reply) but that is assuming the data is coming into ServiceNow or otherwise populating.



Do you know if that data is being placed into the system?


gemini17
Kilo Guru

Hello Karthik:



you can query like this:



gs.getUser().getRecord().getValue('title');



P.S. Mark it correct and help ful if it works.


Shawn Dowler
Tera Guru

I think you are asking if a user is in the Manager field of any other users, correct? We have similar issues, since the titles won't always tell you. What if they are a director? I want to know that they appear in the manager field. Unfortunately, I think the only way to tell is to do a GlideRecord lookup on the sys_user table and see if any records are returned that contain the current user in the manager field. Something like this should work:



// this assumes the user is the caller on an incident, for example


var user = current.caller;


var grUser = new GlideRecord('sys_user');


grUser.addQuery('manager', user);


grUser.setLimit(1);


grUser.query();


var isManager = (grUser.next()) ? true : false;



Let us know if you still have questions or if this answers your question.