The Salesforce Developers website will undergo maintenance on May 29, 2024 from 3:00 a.m. UTC to 10:00 a.m. UTC. The maintenance process may affect the availability of our documentation. Please plan accordingly.

The pace at which Salesforce continues to innovate never ceases to amaze me. It is Sunday morning and I was going to sit down and point a quick blog about creating a Visualforce page to override the lookup functionality. My requirement was to create a custom, filtered search — something that is a very frequent request from customers.

But since joining Salesforce, I have gotten into the habit of doing two things before development: 
  1. Keeping the release notes from the last few versions in easy access right on my desktop.
  2. Performing a quick search on to see if any ideas already cover my requirement (so I can either add my vote, or see if they are being considered by Product Management)   


This morning, I was excited to have been reminded about a great feature now in Beta release as part of Winter '10: Lookup Filters.  The ideas post provides a great overview of the new feature and lets you rapidly share your feedback with Product Management, with further detail included in the online docs

For the typical requests from customers I have worked with, the current Beta lookup functionality covers the vast majority of requirements, and is great to have this feature now available. 

For those customers where certain features are not included yet (for example, one popular idea is the use of formula fields for more dynamic filters), the platform allows you to override the edit page, and create your own lookup button by leveraging a little Visualforce and some of the Javascript functions already in place within Salesforce:


  <apex:outputLabel value="{!$ObjectType.My_Object__c.fields.My_Field__c.label}" for="my_field"/>

     <apex:outputPanel id="p2">

     <!–  because the field is required, it adds another div in the rendered HTML –>

     <!–   so we need to wrap it to avoid page breaks –>

         <apex:outputPanel id="p3" style="float:left">

             <apex:inputField required="true"  

                              value="{!My_Object__c.My_Field__c}" id="my_field"/>


         <a href="javascript: openPopup(%27/apex/MyCustomSearchPage?id={!My_Object__c.Id}%27, %27CCBCCLookup%27, 420, 490, %27width=420,height=490,toolbar=no,status=no,directories=no,menubar=no,resizable=yes,scrollable=no%27, true);" onclick="javascript: setLastMousePosition(event);" title="My Custom Lookup (New Window)"><img src="/s.gif" alt="My Custom Lookup (New Window)"  class="lookupIcon" onblur="this.className = 'lookupIcon';" onfocus="this.className = 'lookupIconOn';" onmouseout="this.className = 'lookupIcon';this.className = 'lookupIcon';" onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';" title="My Custom Lookup (New Window)"/></a>



But for now, I am excited to see, and encourage you to try out the new Lookup Filters available in Winter '10. Make sure you add your feedback and comments to the ideas site for additional features which will make this new functionality even better.


Get the latest Salesforce Developer blog posts and podcast episodes via Slack or RSS.

Add to Slack Subscribe to RSS