+ Start a Discussion
Anuj Thakur 4Anuj Thakur 4 

how to retrieve self lookup relationship

Hi Team,
I have  a custom field Contact_Self_relationship__c on contact object which is a self lookup to contact itslef.
I have 2 contacts Alen and Josh. In both contact, Contact_Self_relationship__c  field have value as Ana (which is also a contact). Means Ana is parent contact for both Alen and Josh.
Now I am tryning to fetch the Alen and Josh contact record based on the Ana. I tried parent to child and child to parent combinations but I am not getting the list of child contacts. can anyone help me here?
Harsh P.Harsh P.
Hi Anuj,

To retrieve the list of child contacts use the following query:
select Id,LastName,Contact_Self_relationship__c from Contact where Contact_Self_relationship__c = 'Put_Ana_RecordId';
Regards,
Harsh P.
 
Anuj Thakur 4Anuj Thakur 4
HI harsh,
Thanks for the clarification, anyhow I also got it :) :)
Harsh P.Harsh P.
Can you provide your solution to help other Peoples.