0

This question already has an answer here:

I have a problem to attempt to the Order object based on the custom Contact lookup. I use the query:

select Id, (select id from Orders ) from Contact

and the object looks like that: enter image description here

The error is:

Didn't understand relationship 'Orders' in FROM part of query call.

marked as duplicate by glls, David Reed Aug 8 at 12:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

As this is a custom relationship between Contact and Orders, you will have to use __r with the child relationship name.

So your query should be

select Id, (select id from Orders__r) from Contact

You can get further information about the custom relationship name and how to use parent to child relationship queries at this salesforce documentation Understanding Relationship Names, Custom Objects, and Custom Fields

  • +1. Good explain. – salesforce-sas Aug 7 at 11:07
  • Hi @Quicki if this or any answer has solved your question please consider accepting it by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both the answerer and yourself. There is no obligation to do this. – Vijay Ganji Sep 3 at 9:42

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