I'm showing up with another problem:

I'm building a VF PDF page based on Opportunity object and I want to add a paragraph that shows all contacts related to this Opportunity.

My approach was as following:

<apex:outputText rendered="{!Opportunity.Show_User_Statement__c}">  
                <p style="margin-top: 30px;">
                <strong>The licensed users are:</strong>

              <apex:repeat value="{!Opportunity.Contact}" var="user">
                  <apex:OutputField value="{!user.Name}"/> <br/>


But my problems started as I've found out, that there's no simple way to access Contacts from Opportunity. Is there a way without Apex (only professional licence available)?

And how could I make sure only Opportunity related contacts are shown?

Greets and many thanks for your help!!

1 Answer 1


You can use the OpportunityContactRoles relationship:

<apex:page standardController="Opportunity">
  <apex:datatable value="{!Opportunity.OpportunityContactRoles}" var="role">
    <apex:column value="{!role.Contact.Name}" />
    <apex:column value="{!role.Contact.Email}" />
    <apex:column value="{!role.Contact.Phone}" />

Note that you'll get a default sort order, which cannot be changed without the use of client-side code (JavaScript).

  • Hi, thanks for your suggestion. Sometimes its quite simple, but honestly I'm new to Salesforce :)
    – Dennis1995
    Jan 14, 2021 at 17:52
  • @Dennis1995 We're all here to learn and to teach. I'm glad I was able to help you out! Keep with it, it'll be second nature soon enough.
    – sfdcfox
    Jan 14, 2021 at 19:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .