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
Zoom_VZoom_V 

Lookup fields Visualforce

I'm trying to find the properly way to display a lookup field on a Visualforce for a custom object/field. All of the examples I keep seeing are for standard fields (AccountID ; UserID). 

<apex:inputfield id="Vendor_Classification__c" value="{!Vendor_Classification__c.Vendor__c}" required="true"/>

What is the proper syntax to display the Vendor__c lookup field as a link ?
Himanshu ParasharHimanshu Parashar
Hi,

If you want to display that as a link you need to use <apex:outputfield> tag instead of <apex:inputfield> as shown below
 
<apex:inputfield id="Vendor_Classification__c" value="{!Vendor_Classification__r.Vendor__c}"/>

Let me know if that help you.


Thanks,
Himanshu
Vivek DeshmaneVivek Deshmane
Hi,
If you want to show lookup link as readonly then try below code. let me know if this works for you.
<apex:outputField value="{!Vendor_Classification__c.Vendor__c}"/>

Best Regards,
-Vivek
 
William TranWilliam Tran
The lookup will automatic show as an magnifying glass.  What's wrong with you code, does it not work? 

thx.