You need to sign in to do that
Don't have an account?

Getting all Manager Id
Hi Everybody,
Can anyone tell me how to get all managers id based on the user id??
like user-->manager1-->manager2-->manager3--->manager4
My code is:
public static List<Id> getParrentId(Id i){
List<Id> ParentUserId=new List<Id>();
User ur = new User();
ur = [select Id, Name, ManagerId from User where Id =: i];
if(ur.ManagerId != null)
ParentUserId.addAll(getParrentId(ur.ManagerId));
return ParentUserId;
}
But it doesnt get all parent id??
Thanks in advance
Karthick
Can anyone tell me how to get all managers id based on the user id??
like user-->manager1-->manager2-->manager3--->manager4
My code is:
public static List<Id> getParrentId(Id i){
List<Id> ParentUserId=new List<Id>();
User ur = new User();
ur = [select Id, Name, ManagerId from User where Id =: i];
if(ur.ManagerId != null)
ParentUserId.addAll(getParrentId(ur.ManagerId));
return ParentUserId;
}
But it doesnt get all parent id??
Thanks in advance
Karthick
public static List<Id> getParrentId(Id i){
boolean bln = false;
id UserId = i;
List<string> lst = new List<string>();
User u = new User();
while(bln == false)
{
u = [select id, manager.name, managerid from user where id = :UserId];
if(u.managerid == null)
{
bln = true;
}
else
{
lst.add(u.manager.name);
UserId = u.managerid;
}
}
return ParentUserId;
}
Please Mark this as Answer if it helps you
--
Regards,
Grazitti Team
Web: www.grazitti.com
All Answers
public static List<Id> getParrentId(Id i){
boolean bln = false;
id UserId = i;
List<string> lst = new List<string>();
User u = new User();
while(bln == false)
{
u = [select id, manager.name, managerid from user where id = :UserId];
if(u.managerid == null)
{
bln = true;
}
else
{
lst.add(u.manager.name);
UserId = u.managerid;
}
}
return ParentUserId;
}
Please Mark this as Answer if it helps you
--
Regards,
Grazitti Team
Web: www.grazitti.com
I wanna gather all manager ids(Manager1.id,manager2.id,manager3.id and etc)
Not name
Please Mark this as Answer if it helps you
--
Regards,
Grazitti Team
Web: www.grazitti.com