function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
amarnijeramarnijer 

How to create a tree view?

Hi, I want to create a tree view with checkbox option based on the logged in user. When the user logged in , he can see a tree  with him as a root nodes and his subordinates as sub nodes. Then he can chose any user and the user`s Id should be display in bottom. I got a code from the link below

 

http://forceguru.blogspot.in/2011/12/displaying-role-hierarchy-on.html

 

But this returns me a tree from the beginning, not as logged in user.

Thanks.

Best Answer chosen by Admin (Salesforce Developers) 
amarnijeramarnijer

I solved by placing "Userinfo.getUserId()" in "return RoleUtil.getRootNodeOfUserTree(Userinfo.getUserId());"  and " public RoleUtil.RoleNodeWrapper getRootNodeOfTree(Id roleOrUserId)"

 

public RoleUtil.RoleNodeWrapper getRootNodeOfTree(Id roleOrUserId)
{
return RoleUtil.getRootNodeOfUserTree(Userinfo.getUserId());

}

public String getJsonString()
{
String str = null;
str = RoleUtil.getTreeJSON(Userinfo.getUserId());
return str;
}

All Answers

amarnijeramarnijer

I solved by placing "Userinfo.getUserId()" in "return RoleUtil.getRootNodeOfUserTree(Userinfo.getUserId());"  and " public RoleUtil.RoleNodeWrapper getRootNodeOfTree(Id roleOrUserId)"

 

public RoleUtil.RoleNodeWrapper getRootNodeOfTree(Id roleOrUserId)
{
return RoleUtil.getRootNodeOfUserTree(Userinfo.getUserId());

}

public String getJsonString()
{
String str = null;
str = RoleUtil.getTreeJSON(Userinfo.getUserId());
return str;
}

This was selected as the best answer
pramod sharma 15pramod sharma 15
I need to create a dynamic picklist with all the names of subordinates based on the user role who is logged in. Is there any easy way to get the subordinate id and name?