+ Start a Discussion
Tobias HaggeTobias Hagge 

Display field from related object

I am building a Visualforce page for the Opportunity custom console. I want to build a page with the basic contact information, how do I get the contact fields? I created a lookup(Contact) on the Opportunity
<apex:page standardController="Opportunity"  showheader="false" >
    <apex:form >
    <apex:pageBlock >
    
         <apex:pageBlockSection collapsible="false" columns="5">
             <apex:pageblocksectionItem >
             <apex:inputField value="{!Contact.Email}"/>
             </apex:pageblocksectionItem>
             
         </apex:pageBlockSection>  
         
    </apex:pageBlock>
    </apex:form>
        
</apex:page>
How can I modify this?

Thanks

Best Answer chosen by Tobias Hagge
Subhash GarhwalSubhash Garhwal
Try this one
<apex:inputField value={!Opportunity.Contact_Name__r.Email} />

All Answers

Subhash GarhwalSubhash Garhwal
Hi Tobis,

If Lookup(Contact) field's API name on opportunity is Contact__c than you can get contact information by this way
<apex:inputField value="{!Opportunity.Contact__r.Email}"/>

Thanks



Tobias HaggeTobias Hagge
gives me the following error:

Error Error: Could not resolve the entity from <apex:inputField> value binding '{!Opportunity.Contact_Name__c.Email}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable.
Subhash GarhwalSubhash Garhwal
Try this one
<apex:inputField value={!Opportunity.Contact_Name__r.Email} />

This was selected as the best answer