1
List<Opportunity_Payment__c> opp = [SELECT Id,(SELECT Owner.Id FROM Opportunity__r) FROM Opportunity_Payment__c];
  • Opportunity_Payment__c has master-detail relationship field to the opportunity.

**ERROR: **Didn't understand relationship 'Opportunity__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.

1
  • List<Opportunity_Payment__c>*** Commented Sep 19, 2016 at 15:21

1 Answer 1

1

If Opportunity_Payment__c has a master-detail relationship field(let's call it oppParent) to Opportunity object, it means that you'll have just 1 parent per Opportunity_Payment__c, hence your query should be a children to parent query (Right Outer Join):

List<Opportunity_Payment__c> opp = [SELECT Id, oppParent__r.Owner.Id
                                    FROM Opportunity_Payment__c];

What you're using in your query is a parent to child relationship query (Left Outer Join), which would be ok if you run it for opportunity sobject:

List<Opportunity> opp = [SELECT Id, (SELECT Id FROM Opportunity_Payments__r)
                                    FROM Opportunity];

More info

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .