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

Need to get owners manager details based on Role Hierarchy
Assume VP-->Lead-->Rep hierarchy structure.
Owner may be Lead/Rep. Need to get details of VP for both of them.
If owner is Rep---Need the user in VP(2 levels up)(assuming only one user per role VP wise as set in org).
If Owner is Lead---Need the user in VP(1 level up)(assuming only one user per role VP wise as set in org)
Please find below code
public static set<Id> getSubordinateRoles(Id roleId) {
map<Id, set<Id>> parentAndChildren = new map<Id, set<Id>>();
set<Id> children;
for(UserRole ur : [select Id, ParentRoleId from UserRole]) {
children = parentAndChildren.containsKey(ur.ParentRoleId) ? parentAndChildren.get(ur.ParentRoleId) : new set<Id>();
children.add(ur.Id);
parentAndChildren.put(ur.ParentRoleId, children);
}
return getSubordinateRoles(roleId, parentAndChildren);
}
Any help would be appreciable
Owner may be Lead/Rep. Need to get details of VP for both of them.
If owner is Rep---Need the user in VP(2 levels up)(assuming only one user per role VP wise as set in org).
If Owner is Lead---Need the user in VP(1 level up)(assuming only one user per role VP wise as set in org)
Please find below code
public static set<Id> getSubordinateRoles(Id roleId) {
map<Id, set<Id>> parentAndChildren = new map<Id, set<Id>>();
set<Id> children;
for(UserRole ur : [select Id, ParentRoleId from UserRole]) {
children = parentAndChildren.containsKey(ur.ParentRoleId) ? parentAndChildren.get(ur.ParentRoleId) : new set<Id>();
children.add(ur.Id);
parentAndChildren.put(ur.ParentRoleId, children);
}
return getSubordinateRoles(roleId, parentAndChildren);
}
Any help would be appreciable