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
sekhar maramreddysekhar maramreddy 

how to write lookup field through vf page & apex class

how to write lookup field through vf page & apex class
NagendraNagendra (Salesforce Developers) 
Hi Sekhar,

Please find the working example below.

Let's take an Example:

Suppose you have an Employee Custom Object. In that let's say you have First Name Custom field.

Now you want the lookup icon to be displayed for the above field in your Visualforce page.

In your Controller do the following,
public Employee__c getFirstName()
{
   return [select FirstName__c from Employee__c limit 1];
}
Now, In your Visualforce page do the following.
<apex:inputField value="{!firstName.FirstName__c}"/>
Where firstName is the method name in the Controller.

By doing this a lookup icon will be rendered on ur Visualforce page.

Hope this helps.

Please mark this as solved if the information helps so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Thanks,
Nagendra