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

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
  • life saver!! thanks so much – testing Oct 29 at 18:55

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.