+ Start a Discussion
padmaja shivanepadmaja shivane 

how to map dropdown field to lookupfield in vf

Shashikant SharmaShashikant Sharma
You could use selectList in Visualforce.

<apex:selectList>
<apex:selectOptions value="{!options}"></apex:selectOptions>
</apex:selectList>


Read this : http://www.oyecode.com/2013/01/how-to-render-lookup-field-as-picklist.html

Please mark this as solution if it helps you so that others could be benifitted from it.

Thanks
Shashikant
Abhinav MIshraAbhinav MIshra
public with sharing class yourController
{
    // Defining objects
    public User selectedUser { get; set; }
    public Order__c order { get; set; }

    // Constructor where the user data will be pre-populated
    public yourController()
    {
        order = new Order__c();
        order.User__c = UserInfo.getUserId();
        selectedUser = [ Select Id, Email, Phone From User Where Id = :UserInfo.getUserId() ];
    }

    // Method for reading selected user data
    public pageReference readUser()
    {
        selectedUser = [ Select Id, Email, Phone From User Where Id = :order.User__c ];
        return null;
    } 
}
<apex:outputPanel id="userDetails">
    <apex:pageBlock>
        <apex:pageBlockSection columns="1">
            <apex:inputField value="{!order.User__c}">
                <apex:actionSupport event="onchange" action="{!readUser}" reRender="userDetails"/>
            </apex:inputField>
            <apex:outputField value="{!selectedUser.email}"/>
            <apex:outputField value="{!selectedUser.phone}"/>
        </apex:pageBlockSection>
    </apex:pageBlock>    
</apex:outputPanel>

Thanks!
Reetesh Makkar