+ Start a Discussion
Hariom Chaudhary 1Hariom Chaudhary 1 

How to create dyanamic lookup in visualforce page ?

My requirement is that i have to create a contact create page in which i have fields of contacts. And i want to look account in that dyanamicallly, like when i search accounts it search the accounts.
Khan AnasKhan Anas (Salesforce Developers) 
Hi Hariom,

Greetings to you!

You can just refer the child relationship id in an apex:Inputfield. 
<apex:page standardcontroller="Contact">
    <apex:form>
        <apex:pageBlock>
            <apex:pageBlockSection>
                <apex:inputField value="{!Contact.AccountId}"/>
                <apex:inputField value="{!Contact.FirstName}"/>
                <apex:inputField value="{!Contact.LastName}"/>
                <apex:inputField value="{!Contact.Phone}"/>
                <apex:inputField value="{!Contact.Email}"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons>
                <apex:commandButton value="Save" action="{!Save}"/>
                <apex:commandButton value="Cancel" action="{!Cancel}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Or you can create a custom component. Please refer to the below links which might help you further with the above requirement.

https://opfocus.com/visualforce-autocomplete-lookup-fields/

https://github.com/dieffrei/visualforce-custom-lookup

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Hariom Chaudhary 1Hariom Chaudhary 1
Thank You Sir but the links you provided gives solution of standard lookup but i want dyanamic lookup, like i can search all search all accounts on the contact create  page in account lookup.