+ Start a Discussion
Salesforce Developer 109Salesforce Developer 109 

How to get related records of child from parent object that has hierarchial relationship?

The use case is Account records are connected to other account records using hierarchial relationship. How can i show its child accounts contact records on the parent account page?
Example: Account A- Parent , Account B-Child to A, Account C- Child to A,

How can i display (using VF) on the account A the contact records of Account B and C?
what is the relationship name to query an account itself when in hierarchy relationship?
Any help is highly appreciated.
Abhishek BansalAbhishek Bansal
As per my knowledge hierarchial relationship are only available in User Object.
So does your account object has Self lookup ?

If yes, than you can find the relationship name by foolowing these steps :
  1. ​Go to Account Fields page and select your Field.
  2. There will be a Child Relationship Name column where you can find the relationship name and for Contact you sholud use Contacts as child relationship name.
Let me know if you need more help on this.