+ Start a Discussion

how to create lookup field in vf page



I need to create a lookup for all users where isactive is true and a custom field voltype = bulk.


Please  suggest.



Shashikant SharmaShashikant Sharma

To my knowledge Filter lookup feature the native lookup only works on native page layouts not on visualforce page. You have to create your own lookup page for this. Show it using window.open or showModalDialog , pass the filter criteria in query paramer and show filtered results.


Thanks Shashikant. Can you pls let me know how to do it


Just to clarify, the filtering is applied to the lookup when used on the visualforce page, but not in a useful way!


Rather than restricting the set of values that the user can choose from, an inputfield that is tied to a filtered lookup will let the user choose any value in the system, but will then throw an error when an attempt is made to save the record.


I wrote a blog post regarding building your own Visualforce lookup a while ago at:




and a revised version that used layers as opposed to a popup at:




Both of these contain code samples, so you should be able to use them as a starting point.