Activity Forums Salesforce® Discussions How we can create lookup fields in Visualforce pages in salesforce ??

  • Prachi

    Member
    August 23, 2019 at 5:17 am

    Hi,

    Lets take an Example:
    Suppose you have an Employee Custom Object. In that lets 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.

    Thanks.

    • This reply was modified 5 years, 4 months ago by  Prachi.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos