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
Sunil AroraSunil Arora 

Lookup field


Can we make lookup field in VF  page without using javascript.

Note-The field doesn't exist in database,we just need to use it in UI for selection of a record.

Ron HessRon Hess

you can use inputField to display the lookup, you must have a lookup to that object somewhere ( in a sobject) that you can use.

create an empty object of the type that has the lookup you want, then pass that sobject back to the page (binding) , on the page you use that field in the inputField value and the page will draw with the lookup.

amar joshiamar joshi
well Rone

i  want to make lead convert page that works for convert the lead in account and contact not for opportunity

now problem is that there is "Record Owner" field in which the owner of lead displey in text box

now if i use following code:
<apex:inputtext value="{!}"/>
then owner displayed but no look up displyed so i can change the owner as in standerd lead convert page

please provide any alternative u have

Ron HessRon Hess
to make a lookup to user, you will need a field that is a lookup to user, owner is not.

try owner.manager

you will need to create a user object in your controller, load the manager field with the lead.owner  id, then you can bind in your page to this sobject.

after the user selects the new owner you will have to grab that ID out of the fake user() object and stuff it into the owner field before saving as part of the lead convert process.

the user() object you created is never saved, it's just used to get this lookup.

something like this:

user myfakeuser = new user();
myfakeuser.manager =

amar joshiamar joshi
well rone

i have solve the problem like under::

i have create a new lookup field in lead in which related to user the name of field is "Record Owner" and API is Record_Owner__C

the field value is empty right now

the apex page code is :

<apex:inputfield value="{!lead.Record_Owner__c}"/>

the controller code is:

public Lead getLead() {
          Lead a;
         a= [select,owner.type,,Record_Owner__c from Lead
                 where id = :ApexPages.currentPage().getParameters().get('id')];
         return a;

now at lead convert process i will map this field value to Lead owner name

so is the correct way that i code??????????

please advice or any other alternative