Extract unique list of users who are managers

Sooriya3
Giga Guru

Hi

I have a requirement to extract a unique list of users who are managers. Anyone familiar with this kind of request and ideas to? I am able to filter on manager!empty, but then not a unique list.

5 REPLIES 5

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Sooriya3 

On which table are you creating the report? And how do you identify if a user is a manager, such as by designation or other parameters? You can try using reporting and add the filter like this.

 

Report type: Bar

 and select count distinct

AGLearnNGrow_0-1744214028498.png

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

That is the challenge. There are no fields that classify a user as a manager. AD captures the name of the manager into the manager field. For those existing already in the system, would need to write a script to achieve a list of unique users who are also managers

Hi @Sooriya3 

Are you asking if you want to know which users are managers and have been added as managers in the "manager" field of the user table? Is my understanding correct? Could you provide an example or a screenshot to clarify?

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

SourabhAkiwate
Tera Expert

 Hi @Sooriya3 , Good Afternoon,

Please try out the below script to get the unique users who are manager of multiple groups.

 

var user=[];
var grp=new GlideRecord("sys_user_group");
grp.addEncodedQuery('manager!=NULL');
grp.query();
while(grp.next())
{
    user.push(grp.manager.user_name.toString());
}
gs.info("user list: "+user);
gs.info("user count is :"+grp.getRowCount());

var man=[];
var manager=new GlideRecord("sys_user");
manager.addEncodedQuery('user_nameIN '+user);
manager.query();
while(manager.next())
{
    man.push(manager.user_name.toString());
}
gs.info("manager list: "+man);
gs.info("manager count is :"+manager.getRowCount());
 
 
If my solution works for you, please respond by selecting " Accept as Solution" and " Helpful."
Thank you.
Sourabh A.