I want to return all the opportunity contact roles for each opportunity where it's roles for an Opportunity, and I want to access a field in the contact role. my query looks ok, but I can't access the fields directly in Apex. Also, how do I access this in Visualforce?
Opportunity opp = [SELECT id, Name, StageName, (select contact.name, contact.phone from OpportunityContactRoles where isPrimary = true ) FROM Opportunity where id = '006e0000003V3NNAA0']; system.debug(opp.OpportunityContactRoles.contact.id);
Invalid foreign key relationship: Opportunity.OpportunityContactRoles