0

I can't seem to figure this one out. I have 3 objects- Case, Contact, & Purchases (custom).I am writing a SOQL query on Purchases that needs a field from Contact. There is a Master-Detail relationship from Purchases to Case (field name Case__c), and a Lookup Relationship from Case to Contact (field name ContactId). Besides this, Purchases and Case aren't related.

I've been trying the following but I keep getting Didn't understand relationship 'ContactId__c' in field path. errors, could anyone help me figure out what I'm missing?

[SELECT Case__r.ContactId__r.Fixed_Wholesaling_Channel__c FROM Purchases__c]

Thanks

1 Answer 1

3

__r is used for traversing custom relationships, not standard ones. Case.ContactId is a standard relationship, which you traverse by removing the Id suffix:

SELECT Case__r.Contact.Fixed_Wholesaling_Channel__c FROM Purchases__c
1
  • life saver!! thanks so much
    – testing
    Oct 29, 2019 at 18:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .