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
Lakshmi Gupta 4Lakshmi Gupta 4 

Custom table having three lookup relationship to contact table.

Hi,

I have created a custom object Attendance__c with three fields called contact__c, manager__c, manager's manager__c. They are all lookup relationship with contact object. I want to get these three names in my apex code. I'm able to get the contact__c with the below:
Select contact__r.name from attendace__c.  How can I get the names of manger and manager's manager which is lookup relation to contact object? Thanks for your help!!

User-added image
 
Andrew GAndrew G
Assuming you mean from the one record
If each manager is also a contact that is set in the creation of the Attendance record
Select contact__r.name, manager__r.Name, managersmanager__r.Name from attendace__c

If we are talking about doing a automated related lookup based on the first contact record, then a different story.

Regards
Andrew