9

I'm getting an error - didnt understand relationship when running this query in dev console. I have set the child relationship the lookup field to IncEvents. The lookup field is on the MyRule object -

select Id, Name, (select Id from IncEvents_r) from Namespace_MyRule__c

I noticed that the editor is displaying a single underscore between the namespace and the object name but I did enter a double underscore.

  • do you have eclipse or force.com IDE installed ?This type of issue are easy to identify using eclipse schema builder – Mohith Shrivastava Nov 9 '13 at 6:44
  • thanks Eclipse schema helped. Although the relationship appears to be the opposite to what I had expected. This returns results - select Id, Name, (select Id from MyNamespace__IEvent__c.MyNamespace__IncEvents__r) from MyNamespace__IEvent__c – wisemanIV Nov 9 '13 at 6:53
  • @wiseman1V I have answered this as well as how to do step by step .Hope this helps – Mohith Shrivastava Nov 9 '13 at 6:58
11

Lets explain this with an example

I have a two custom objects named Position__c (Parent) and Job_Posting__c(Child).

Here is how I will approach the query

  1. First I will go to the child object sreen

    Custom Object Definition Detail

  2. Next I will go to the parent lookup field and click on it to find child relationship name

    Custom Field Configuration

  3. Next step will be to write the query in the query editor of developer console properly

    Select id,name ,(Select Id,Name from Job_Postings__r) from Position__c
    

    Developer Console Query Results

Note: Be sure to include a Namespace Prefix when one is listed on the sObject. For example, a Parent/Child object with a "ns" prefix would have a query like this:

select id, name, 
(select id, name from ns__Child_Relationship_Name__r) 
from ns__Parent_Object__c

An interesting thing is developer console now supports the sub-query .

  • I think where I got confused was understanding which of my objects was the parent and which was the child. A field name like child relationship name suggested to me that the object containing this field was the parent. – wisemanIV Nov 9 '13 at 7:07
  • @wisemanIV So the above answer is right for anyone encountering the error and if he glances this answer .Also if something answers your question please make sure to tick the answer – Mohith Shrivastava Nov 9 '13 at 7:10

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.