Account Hierarchy View

Client would like to be able to launch a skuid view off of any Account record that will then display all the related records for ANY account in the hierarchy. So for example, say we have a hierarchy that looks like this:

Parent Account

Child Account

Grandchild Account
Grandchild Account

Child Account
Child Account

The want to be able to launch a skuid page that will allow them to see all the contacts related to any of these accounts (And cases, opportunities, etc) from any account within the hierarchy. Is this possible or will they always need to start from the Parent account for the correct context?

The other piece is - how can we be sure we are capturing the entire hierarchy? Meaning how can I be sure that I am accounting for all related accounts? The hierarchy could have many levels. How to I make sure that the user can see all records related to all accounts if i don’t know how many levels deep the hierarchy could be?

Yes! Show me all the data!!!

This is possible, but only within limits. Within a new skuid page, create a model on Contacts that has a separate condition for every level of hierarchy you allow. Because you can traverse up the levels of the data model when picking the fields you want to use in your condition you can get to Account.Parent.ParentId which is the grandparent.

The important detail is to use the “Grouping logic” property of conditions to connect these conditions with OR operators. This will return data if ANY of these conditions are true.

Add that model to a table and you are in business. Rinse and repeat for all the other related objects…

So, add a condition for every level of the hierarchy you expect. If your hierarchy is truly limitless - we can’t help you. But we can get you close…

Thanks Rob. They say its limitless but I will push them on that and see what shakes out. The rest makes sense. Thanks for the reply.

@Rob_Hatch This only works moving down the hierarchy. So if I launch from Child Account in my example above, it only shows contacts for Child and Grandchild, not Parent. Any ideas to get this to work if they are launching the view from any account in the hierarchy. I think I have been staring at it for too long - I can’t figure it out.

Oh. This is a fun wrinkle…

What this means is that you have to build a process that finds the ultimate parent - and then use that account ID to drive the queries of related records. Fortunately - I think that with an action sequence you can build a recursive process that traversese up the hierarchy.

So the first thing your process will do is load the current account into a separate model - lets call it “StartingAccountFinder”. I think the only field needed will be parent account ID and current account.

Then on this new model create a “model action” that executes whenever it is queried.
The sequence in this action looks like this:

  1. Branch. If Parent Account has a value pass that value into the condition for the “StartingAccountFinder” and requery that model.
    Make sure the branch “Does NOt run additional actions” after it is run.

  2. If NO Parent Accounts are found - you know you are at the top and you can pass this ID into the process we built above.

My sketch is pretty rough - but hopefully it will get you unstuck!

@Rob_Hatch I’ll test this out tomorrow. Thanks for helping to unstick me - much appreciated!!!