You need to sign in to do that
Don't have an account?
Carole Reynolds1
VP Page standardController Opportunity - Get Contact Name from Contact Roles
I have a VF page that uses the standardController for Opportunity. Is there a way, without writing an extension class, to get the Contact Name from the Contact Roles related list?
I found a solution for my email template that works like a charm (see below), but I'm struggling getting it to work on the VF page that is used by a custom button. I'm a developerless novice admin, pardon my ignorance.
Working in VF Email Template:
<apex:repeat value="{!RelatedTo.OpportunityContactRoles}" var="ContactRole"> {!ContactRole.Contact.Name}</apex:repeat>
Example 1 uses the related list component to render the contact roles related list onto the page. It will look like the related list displayed on the standard opportunity page layout.
Example 2 uses the pageblocktable component to iterate through the list of contact role records. The column component is used to render individual field data onto the table.
All Answers
Example 1 uses the related list component to render the contact roles related list onto the page. It will look like the related list displayed on the standard opportunity page layout.
Example 2 uses the pageblocktable component to iterate through the list of contact role records. The column component is used to render individual field data onto the table.
@Terence_Chiu Thank you so much, based on what you provided I was able to write exactly what I needed. In my scenario there is always only going to be one contact in the contact role on a given opportunity, so I didn't need to worry about the role itself. In the email template the repeat value is done like {!RelatedTo.OpportunityContactRoles}. I didn't know how that translated for this page, and your answer pointed me in the right direction.
<apex:repeat value="{!Opportunity.OpportunityContactRoles}" var="cr">{!cr.Contact.Name}</apex:repeat><br/>
Your help has been greatly appreciated!