0

I'm having trouble putting together a SOQL query.

Basically i have a parent object (Opportunity), with multiple child objects (Borrower_Pair__c). The relationship from the child to parent is created through a master-detail field (Owner_Application__c) on the child (Borrower_Pair__c).

The goal is to get the ids of the all the child objects.

Here is what i have so far...

List<sObject> borrPairIds = [SELECT Id FROM Borrower_Pair__c WHERE Owner_Application__c.Id = :oppId];

Where :oppId is the Id of the opportunity. However when i run this, i get the error in the title.

The full error is

Didn't understand relationship 'Owner_Application__c' in field path. 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. (31:37)
1

Change Owner_Application__c.Id to Owner_Application__c. Alternatively, you could use Owner_Application__r.Id but you should avoid the crossobject reference as it is not necessary.

0

Owner_Application__c itself represents the Id of Opportunity to which your child object is related to.

You will need to simply use Owner_Application__c in your SOQL:

SELECT Id FROM Borrower_Pair__c WHERE Owner_Application__c = :oppId;

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.