+ Start a Discussion
Melissa HowardMelissa Howard 

VF lookup field not working

I have an extended controller for the Contact object that is not being picked up by Visualforce.

The VF line that isn't working is the which I want to be a lookup field is:

                <apex:inputField id="RequestedBy" value="{!contactSetting}" />
                 Error =
Error: Could not resolve the entity from <apex:inputField> value binding '{!contactSetting}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable.  

    <apex:form >
        <apex:pageBlock title="Foodbank of Santa Barbara County Volunteer Information">
            <apex:pageBlockSection columns="1">
                <!-- <b>Input Date  :</b><apex:inputfield value="TODAY"/> This gives error, even if value="7/21/2014"
                <apex:outputLabel value="Lookup Contact" for="ContactLookup"/
                <apex:inputField id="RequestedBy" value="{!contactSetting}" />

The APEX is:

public with sharing class ContactExtendedController {

    public Contact contactSetting{get;set;}

    public ContactExtendedController(ApexPages.StandardController Contact) {
        contactSetting=new Contact();
    public ContactExtendedController() {
        contactSetting = [SELECT Id, Name FROM Contact
                   WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
        // if (contactSetting == null)
        //    System.debug('Contact Doesn't Exist. Contact the Foodbank.');
Could you please post your full page code? Specifically <apex:page> block at the top of the page
Anoop yadavAnoop yadav

You should use:
<apex:inputField id="RequestedBy" value="{!contactSetting.Name}" />

instead of
<apex:inputField id="RequestedBy" value="{!contactSetting}" />

Because "contactSetting" is returning object, not a field value.
Hi Melissa...

try this...example...

<apex:page controller="custlookup">

    <apex:form >
        Account <apex:inputField value="{!c.CampaignID}"/>


public with sharing class custlookup {

    public Oppourtunity c { get; set; }
    public anand_custlookup(){
        c = new Oppourtunity();
Ramakrishnan AyyanarRamakrishnan Ayyanar
Can you post your full vfpage code ?

then only find out extact answer
Hi Melissa...

Always remember that Inputfield tag can be used only when you are accessing the sObject Fields...

To do that first you need to create a handler of the type sObject and use this handler in Vf to access the fields...

check the following example...

<apex:page controller="Cust_cntrl">

    <apex:form >
        First Name<apex:inputField value="{!c.FirstName}"/>


public with sharing class Cust_cntrl{

    public Lead c { get; set; }
    public Cust_cntrl{
        c = new Lead();