+ Start a Discussion
InnovationInnovation 

VisualForce inputField not respecting lookup filters in search results

I came across another post similar to this but there was no solution posted, so I am going to attempt to raise the issue again - I have a custom UI built in VisualForce, and I've noticed that any lookup fields that have Lookup Filters established do not display filtered search results - they search window shows results that are outside of the filter criteria.  Yet when an option is selected that does not meet the filter criteria, the following error is generated:

 


Insert failed. First exception on row 0; first error: FIELD_FILTER_VALIDATION_EXCEPTION, Value does not exist or does not match filter criteria.: [EXAMPLE_FIELD__c]

 

 

I have not been able to find any documentation related to forcing a VF component to respect the Lookup Filter behavior.  If I create a new record for the object in the standard UI, the lookup filter works as it should with regard to the search results.  How do I reconcile this discrepancy in functionality between VisualForce and the standard UI?

 

 

Thanks,

 

Mike


JNicJNic

I'm suffering the same affliction and just posted here:

http://boards.developerforce.com/t5/Visualforce-Development/Lookup-filters-not-respected-by-visualforce-input-field/td-p/248377

 

 

The release notes here say it's supposed to work...

http://success.salesforce.com/ideaView?c=09a30000000D9xt&id=08730000000BrZSAA0

 

 

did you ever figure it out?

InnovationInnovation

Well, I figured out that I couldn't wait for salesforce.com to figure it out.  :)

 

We ended up writing custom selectoption list methods in the controller to get the filtered dataset as a workaround.  We tested again when the dev sandbox was upgraded to Spring '11, but no dice...same result.  Really interesting that the validation would be enforced at runtime prior to insert / update, but that there's no integration with the view.

 

 

CAfromCACAfromCA
I know this is almost 3 years too late, but for posterity it appears you need to have the lookup field you are filtering as well as any fields it depends on in the Visualforce page for the filter to be used.

I had created objects that have lookups to Account and Contact, and I filtered the Contact  lookup such that only records attached to the selected Account were displayed/allowed. I was pre-filling the Account lookup, but had this same issue with my own VF interface until I added that field to the page.

The controling field(s) apparently only need to exist on the page; I hid them using CSS and the filter still seems to work fine.