+ Start a Discussion

Need tro create a Hierarchy page for a lookup field (similar to account view hierarchy)

I have several fields in y account page that I need to add a functionality very similar to the account hierarchy page that displays when clicking [view hierarchy].  These fields represent other relationships to other accounts and my users would need to be able to view those relationships in the same way, with parent accounts and even grandparent accounts just like below:


click the link from Account 'abc', need to view any accounts at the same level and parent accounts, and any parent of that parent if any.


Result: (example) need the indenting and all.


Grandpa Account









        Account abc (this is the Acc. from where we clicked view hierarchy) 

                child acc 1

                child acc 2

                child acc 3



Any idea as to how can I achieve this?


Sounds to me like a job for wrapper classes.


Create a class or classes that models this hierarchical relationship and make this available as a property from your controller.  Then use a combination of vanilla HTML tables and apex:repeat tags to walk the structure.  When outputting the properties, you can add highlighting based whether the account matches your chosen account.




D oyou have any example code that would help me out a bit, I am not entirely sure how to do this.


Thank You.