function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michael BobeeMichael Bobee 

Display the Opportunity Contact Role for one Contact

I would like to traverse the relationship between an Opportunity and the ContactRole related list. We only choose one contact for each Opportunity, so there's no need to filter a sub-query. We are rendering a VisualForce page as a PDF, so the intention is to use <apex:outputField value="{!Opportunity ..." - dot notation. The Opportunity is the StandardController. Can a related list be referenced? (<apex:relatedList list="Contacts" ...) This is my second day trying to drink from a fire hose.(I'm getting bloated!) Thank you. Are there any good books to start from ground zero?
Vishant ShahVishant Shah
You can do a query like

[select id, (select id, name from opportunityContactRole) from Opportunity where id = :oppId]
 and add the opportunitycontactrole in a <apex:repeat> tag to show opp.opportunityContactRole.Name 


OR 

Write a trigger on oppContact role to populate a field on opportunity, this way you can directly use it in a Visual force page

Ta
Vish
Michael BobeeMichael Bobee
Since the second option is not possible(I entered a trigger into the developer console, and it informed me that the object was not supported.), I guess I will focus on the first suggestion. Where do I find documentation to find out more information on deriving this solution? (To find OpportunityContactRole.ContactId.Name and save it on a custom field on the opportunity.)