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
Supriya P 9Supriya P 9 

Didn't understand relationship 'OpportunityOrder__r' in FROM part of query call

I have two objects
1) Opportunity(Master Object)
2)OpportunityOrder__c (Child object) .  
When i query the object,
SELECT id,name,Opportunity_Number__c,(SELECT id,name,Order_Number__c from OpportunityOrder__r) from opportunity.
it throws me an error message saying 
(SELECT id,name,Order_Number__c from OpportunityOrder__r) from opportunity
                                     ^
ERROR at Row:1:Column:75
Didn't understand relationship 'OpportunityOrder__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.

I would be glad if somebody can help me find a solution for this. 
Thank you.
 
Best Answer chosen by Supriya P 9
Nayana KNayana K
If Opportunity's child object name is OpportunityOrder__c then its child relationship name need not be OpportunityOrder__r. It depends on what you have given while creating lookup/MD to Opportunity.

For eg :

Here Contact is parent, Opportunity is child.

While creating lookup to Contact from Opportunity I have given 'Child Relationship Name' = 'Opp' rather than accepting default name.

User-added image

So my query will be 
SELECT Id, (SELECT Id FROM Opp__r)  FROM Contact

All Answers

Nayana KNayana K
If Opportunity's child object name is OpportunityOrder__c then its child relationship name need not be OpportunityOrder__r. It depends on what you have given while creating lookup/MD to Opportunity.

For eg :

Here Contact is parent, Opportunity is child.

While creating lookup to Contact from Opportunity I have given 'Child Relationship Name' = 'Opp' rather than accepting default name.

User-added image

So my query will be 
SELECT Id, (SELECT Id FROM Opp__r)  FROM Contact
This was selected as the best answer
Supriya P 9Supriya P 9
Yeah it worked.
Thanq Nayana .. :) 
Priyanka Jadhav 54Priyanka Jadhav 54
yesss it worked Nayana .... tysm