+ Start a Discussion
BarryPlumBarryPlum 

Access email of primary contact on Opporunity

I've created a visualforce page that uses the Opportunity controller to iterate through the opportunity line items and I want to reference the email value from the contact that's marked Primary on the Opportunity.

This seems pretty straightforward, but I'm not sure how to do it.

I've been able to traverse the relationships to get to field values on the other objects, but essentially I have to do a query to get the ContactId from OpportunityContactRole where IsPrimary is true and then use that Id to get the email address from the contact object.

I could probably create a controller extension to do this, but it seems like it should be possible with a formula in a merge field.

Thanks in advance.

Barry