function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AmbujAmbuj 

Subquery not working

Can someone tell me why the subquery is throwing an error in developer console...????
Opportunity opp = [Select Id, (Select Id, Status__c from Object__r where Status__c = 'Waiting for their Turn') from Opportunity where Id = 'XXXXXXXXXXXXXXX'];
Object__c is detail to Opportunity ....

Error is:
"Didn't understand relationship 'Object__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names."

Its urgent.. Thanks..!!!

Best Answer chosen by Admin (Salesforce Developers) 
Santosh KumbarSantosh Kumbar

Opportunity opp = [Select Id, (Select Id, Status__c from Object__r where Status__c = 'Waiting for their Turn') from Opportunity where Id = 'XXXXXXXXXXXXXXX'];

 

Highlighted object name should be a relationship name.

 

you can take that name from : GO to Object__c --> open Opportunity lookup/Masterdetail field there you can see 'Child Relationship Name'  e.g : objects__r

 

 

 

Regards

Santosh

www.santoshkumbar.com

All Answers

Santosh KumbarSantosh Kumbar

Opportunity opp = [Select Id, (Select Id, Status__c from Object__r where Status__c = 'Waiting for their Turn') from Opportunity where Id = 'XXXXXXXXXXXXXXX'];

 

Highlighted object name should be a relationship name.

 

you can take that name from : GO to Object__c --> open Opportunity lookup/Masterdetail field there you can see 'Child Relationship Name'  e.g : objects__r

 

 

 

Regards

Santosh

www.santoshkumbar.com

This was selected as the best answer
jd123jd123

Hi Ambuj

 

Opportunity opp = [Select Id, (Select Id, Status__c from Objects__r where Status__c = 'Waiting for their Turn') from Opportunity where Id = 'XXXXXXXXXXXXXXX'];

 

write your child name I thinks the child name is Objects__r

 

you can understand more 

 

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_relationships.htm

 

 

if your question resolve please mark it as accept as a solution if not please let me know.