Select Name, Contact.Name ,Pension_Contract__c.Contact.Account.Name From Pension_Contract__c Where Signing_Status__c = 'Completed'
Why do I get this error ?
Is this the wrong way of querying from child to parent ?
Select Name, Contact.Name
,Pension_Contract__c.Contact__r.Account__r.Name
^ ERROR at Row:1:Column:14 Didn't understand relationship 'Contact' in field path. If you are attempting to use a custom
relationship, be sure to append the '__r' after the custom
relationship name. Please reference your WSDL or the describe call for
the appropriate names.
Best Answer
If you need to return a custom field value from parent object, simply reference the Lookup/Master-Detail field's API name and change the
__c
to__r
.If your lookup field API name is
Contact__c
, then useContact__r.somefield
For example: