You need to sign in to do that
Don't have an account?

Parent-to-child relationship query
My objects are:
Object: Partner_Sent__c (object used for Many-to-Many)
Fields: CVB_Partner__c (Lookup to CVB_Partner__c object), Opportunity__c (Lookup to Opportunity object)
Object: Opportunity
Fields: Id, Name, Partner_Selected__c (Lookup to CVB_Partner__c)
Object: CVB_Partner__c
Fields: Id, Name
I want to do a query that gives me all CVB_Partner__c objects with the related Partner_Sent__c where the Partner_Selected__c is equal to the parent partner.
The code is much easier to understand:
Unfortunately, I'm getting an error that states CVB_Partner__r.Id is not a valid field.
Am I doing something wrong or is this even possible?
Thanks!
Object: Partner_Sent__c (object used for Many-to-Many)
Fields: CVB_Partner__c (Lookup to CVB_Partner__c object), Opportunity__c (Lookup to Opportunity object)
Object: Opportunity
Fields: Id, Name, Partner_Selected__c (Lookup to CVB_Partner__c)
Object: CVB_Partner__c
Fields: Id, Name
I want to do a query that gives me all CVB_Partner__c objects with the related Partner_Sent__c where the Partner_Selected__c is equal to the parent partner.
The code is much easier to understand:
Code:
Select Id, Name, (Select Id, Name, Opportunity__r.Partner_Selected__c from Partner_Sent__c where Opportunity__r.Partner_Selected__c = CVB_Partner__r.Id) from CVB_Partner__c
Unfortunately, I'm getting an error that states CVB_Partner__r.Id is not a valid field.
Am I doing something wrong or is this even possible?
Thanks!
What I'm aiming for is a lot like the code below, but in a single query.
This is the ideal outcome:
But again, Salesforce tells me CVB_Partner__r.Id is not valid.
Thanks!