You need to sign in to do that
Don't have an account?
How to write Apex class for Role Hierarchies without using Visual Force Page ?
Hello All,
I have a small question that; is it possible - creation of apex class for Role Hierarchy without using VF pages. If answer is YES then tell me How ?
thank you all experts in advance.
Regards'
Taresh Pandey
I have a small question that; is it possible - creation of apex class for Role Hierarchy without using VF pages. If answer is YES then tell me How ?
thank you all experts in advance.
Regards'
Taresh Pandey
You can just go through this link which I think fulfill the requirement:-http://http://blog.jeffdouglas.com/2011/02/15/find-my-salesforce-users-by-role-hierarchy/
Thanks.
All Answers
You can just go through this link which I think fulfill the requirement:-http://http://blog.jeffdouglas.com/2011/02/15/find-my-salesforce-users-by-role-hierarchy/
Thanks.
I think this code helps you for your question
public class RoleUser
{
public class InnerRoleUser
{
public string Name;
public string Id;
public list<InnerRoleUser> SRL;
}
public list<InnerRoleUser> mainparent ()
{
list<UserRole> RL= [SELECT Id,Name,ParentRoleId FROM UserRole ORDER BY ParentRoleId];
list<InnerRoleUser> URL = new list<InnerRoleUser>();
for(UserRole RLR :RL)
{
InnerRoleUser URN = new InnerRoleUser();
if(RLR.ParentRoleId==null)
{
URN.Name = RLR.Name;
URN.Id = RLR.Id;
URN.SRL =childmethod(URN.Id,RL);
URL.add(URN);
}
} return URL;
}
public list<InnerRoleUser> childmethod (string sID , list<UserRole> LR )
{
list<InnerRoleUser> templist= new list<InnerRoleUser>();
for(UserRole INR: LR)
{
if(sId == INR.ParentRoleId)
{
InnerRoleUser tl = new InnerRoleUser();
tl.Name= INR.Name;
tl.Id= INR.Id;
tl.srl= childmethod(tl.Id,LR);
templist.add(tl);
}
}return templist;
}
}
Let me know if you need more help.
Regards
Nishant