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
Paula Kern 4Paula Kern 4 

show lookup field value on visualforce page

Newbie here.  This is giving me the id of the field and I need the name associated with this id in the Accounts object

<apex:column headerValue="DBA Name">
         <apex:outputText value="{!item.DBA_Name__c}"/>
     </apex:column>
Dagny FernandesDagny Fernandes
Hi Kern,

In controller add the following "DBA_Name__r.Name" to your Query. 
Below code in VF page.
 
<apex:column headerValue="DBA Name">
         <apex:outputText value="{!item.DBA_Name__r.Name}"/>
     </apex:column>


 
Siva AnnapareddySiva Annapareddy
Hi Dagny,

I am in a situation where I would like to show some opportunties at certain stage, happy visualforce is rendering required records but when it comes to account name, it is showing as  a link instead of name, couldn't figure out how to fix this?

The above post did help me in rendering contact names, but I am stuck with account name.

Thank you in advance.
Deepali KulshresthaDeepali Kulshrestha
Hi Paula,

Every LookUp field store Id of the related object's record and its string type.

Thatswhy we use "accountid".

So,use this  <apex:inputfield value="{!opportunity.accountid}"/>.

If we want to access any lookup field in visualforce page,use id with field as mentioned above.


I hope you find the above solution helpful.If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha