+ Start a Discussion
lopezclopezc 

I didn't understand relationship 'Content__r'

Hi, 

 

Using Salesforce.schema within eclipse I have created the below SOQL that returns one row:

 

Select (Select IB_Master_Account__c, IB_Prospect__c From IB_Info__r), (Select IB_Account__c, Prospect__c From Content__r), (Select IB_Master_Account__c, IB_Prospect__c From Commerical_Terms__r) From Lead l where id = '00QS0000004Snxg'

 

 

I tried to add the same SOQL to my apex class but when I try to save it in the server it gives me the following error:

 

 

List<Lead> listL = [Select (Select IB_Master_Account__c, IB_Prospect__c From IB_Info__r), (Select IB_Account__c, Prospect__c From Content__r), (Select IB_Master_Account__c, IB_Prospect__c From Commerical_Terms__r) From Lead l where id = '00QS0000004Snxg'];

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

 

 

 

Why is it not working within using apex but it works using either Execute Anonymous or the Salesforce.schema tool?

 

Best Answer chosen by Admin (Salesforce Developers) 
lopezclopezc

I am not using the object "Contract" but the object "Content" instead. I found the problem, I was using an old version of the API. My class was set to version 16.0. I changed it for version 18.0 and then it worked and the relationship was accepted.

 

Thanks for the help

All Answers

lopezclopezc

Any ideas about this?

Pradeep_NavatarPradeep_Navatar

It is because of the error in related object API name. It is not Contract__r. It may Contracts__r. User. Use SF Explorer to find the proper query.

 

Hope this helps.

lopezclopezc

I am not using the object "Contract" but the object "Content" instead. I found the problem, I was using an old version of the API. My class was set to version 16.0. I changed it for version 18.0 and then it worked and the relationship was accepted.

 

Thanks for the help

This was selected as the best answer