Title: Visual Force lookup Filter
Tags: apex;visualforce;controller;lookup;filters
Question: I have a custom visual force page that let you create a new custom object.
In this page there i have a custom lookup to choose the contact.
Do you know if it's possible add a Filter condition to the custom lookup in the controller of the page (select..where)?
Please if you know any code example let me know.
Comment: is the custom lookup a field on your custom object and can you work with the Standard Lookup Filters feature?

Comment: Thank you but it's impossible make my query with the standard filter.


Here is another answer: I don't think it is possible to use apex or soql there ;) But you can put together your own "query" for the lookup filter:
This is a soql-like query then. Here you will find some examples:
Defining Lookup Filters
Lookup Filter Examples
Comment for this answer: Thank you but it's impossible make my query with the standard filter.
Comment for this answer: @Enry Nope :( But it depends on how complex must be your query. For the simple queries it is a good substitution i think.

Here is another answer: You can use Javascript to hyjack the standard lookup action, and instead use your own VF popup page.
You can then do pretty much anything you want, including filters, searches etc. using dynamic SOQL.
Read more on jeffdouglas.com

{'source': 'StackExchangeDataset', 'subset': 'salesforce.stackexchange.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2013:00:05/31/13', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<apex><visualforce><controller><lookup><filters>', 'Title': 'Visual Force lookup Filter', 'ViewCount': 3250, 'id': 12267, 'user_AboutMe': None, 'user_AccountId': 2692280.0, 'user_DisplayName': 'Enry', 'user_Reputation': 3637.0, 'user_Views': 129.0, 'user_id': 2746.0}}