Can anyone tell me how to get the Id of all managers based on the user Id? user-->manager1-->manager2-->manager3--->manager4
I wanna get all manager id
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 does not gather all manager id
Thanks in advance Karthick