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
arishi0arishi0 

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_1

        Account_2 

        Account_3

        Account_4

        Account_5

        Account_6

        Account_7

        Account_8

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

                child acc 1

                child acc 2

                child acc 3

       Account_9

 

Any idea as to how can I achieve this?

bob_buzzardbob_buzzard

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.

 

 

arishi0arishi0

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

 

Thank You.