I have a junction object that links a meeting note to contacts who attended the meeting. It is a master-detail relationship.
How do I get the name of the linked contact too in Apex? It works in developer console query editor, but not in Apex.
This returns the contact names in Developer Console's query editor corectly:
SELECT Meeting_Note__c, Contact__c, Contact__r.Name
FROM Contact_Note_Relation__c
WHERE Meeting_Note__c = 'a000l00000ED5aJAAT'
However this Apex does not work correctly:
System.debug([
SELECT Meeting_Note__c, Contact__c, Contact__r.Name
FROM Contact_Note_Relation__c
WHERE Meeting_Note__c = 'a000l00000ED5aJAAT']);
In Apex the name is not returned. I just get this:
Contact_Note_Relation__c:{
Meeting_Note__c=a000l00000ED5aJAAT,
Contact__c=0030l00000WIAYBAA5,
Id=a060l000005TKgeAAG,
CurrencyIsoCode=USD
}
FYI a060l000005TKgeAAG is the Id of the Contact Note Relation record.
EDIT: I was able to resolve it by adding a Contact Name formula field to the Contact Note Relation object, but I would rather understand how to do this without adding a formula field if possible.