0

I'm trying to retrieve a Salesforce Contact and all their EDA Address records. The Contact lookup field details in the Address object, lists the Child Relationship Name as Addresses Parent Contact Custom field

Following Salesforce's documentation on Parent-to-child relationship queries here:

Parent-to-child relationship queries do not use dot notation:

SELECT LastName__c,
  (
    SELECT LastName__c
    FROM Daughters__r
  )
FROM Mother__c

I ran the following SOQL:

SELECT LastName,
(
    SELECT Name FROM Addresses__r
 )
from Contact WHERE Id = '003f400001XaiGAAAZ'

which fails with the following error

ERROR at Row:3:Column:22
Didn't understand relationship 'Addresses__r' in FROM part of query call. 
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.

Can someone point out how I can change my query to make it valid SOQL?

2

You have to query with the managed package's namespace prepended to the relationship name, when the relationship is packaged:

SELECT LastName,
(
    SELECT Name FROM hed__Addresses__r
 )
from Contact WHERE Id = '003f400001XaiGAAAZ'
| improve this answer | |

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.