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
sandeshdsandeshd 

how to create lookup field in vf page

Hi,

 

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.

sandeshdsandeshd

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

bob_buzzardbob_buzzard

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:

 

http://bobbuzzard.blogspot.com/2010/09/visualforce-lookup.html

 

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

 

http://bobbuzzard.blogspot.com/2011/02/layered-visualforce-lookup.html

 

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