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.

  • Is Pension_Contract__c your relationship field from Pension_Contract__c to Contact? If so, the 2nd field in your SOQL needs to traverse through the custom relationship.
    – TSmith
    Jul 10, 2020 at 10:04
  • Yes, Pension_Contract__c is the child of Contact*Master). Jul 10, 2020 at 10:05

2 Answers 2


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 use Contact__r.somefield

For example:

Select Name, Contact__r.Name , Contact__r.Account.Name
From Pension_Contract__c 
Where Signing_Status__c = 'Completed'

You are using the wrong relationship. Please remove Pension_Contract__c. from the relationship as mentioned below:-

Select Name, Contact.Name , Contact.Account.Name From Pension_Contract__c Where Signing_Status__c = 'Completed'

Refer https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_and_custom_objects.htm to understand the child & parent relationship of custom objects.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.