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
fehays-wbsnfehays-wbsn 

Custom field's lookup filter is not working in a Visualforce page

Hi,

 

I have a custom field on the Opportunity object that contains a lookup field.  If I go to an Opportunity record, and edit it, the lookup filter for that field works correctly (this list of selections is filtered).

 

However, I have a Visualforce page with an apex:inputField associated with this field and the filter is not being applied.  I'm using a standard Opportunity controller.

 

The input field looks something like this:

 

 

<apex:inputField id="customField" value="{!Opportunity.MyCustomField__c}" required="true"/>

 When I click on the lookup icon next to the input field, the list of results shows more than what is supposed to based on the filter in the field settings.


Any help would be much appreciated.  Thanks.

 

bob_buzzardbob_buzzard

I've seen the same thing - unfortunately I've not been able to find a way around this (although not looked that hard TBH).

 

The good news is that if you try to save the record, you will get an error that the value doesn't match the filter, so the filter does get applied, just a bit late.

fehays-wbsnfehays-wbsn

Thanks bob.  Yeah I noticed that at least the filter restriction is respected when the object is updated.