Ross at http://advantageworks.blogspot.com has an interesting idea for filtered lookups in CRM 4.0. I'm frequently asked to filter lookups to make CRM more user friendly, such as filtering a contact lookup to just contacts at a selected company.
His solution is very simple, it uses simple Javasript On Load and On Change of the primary lookup to change the search parameter of the dependent lookup.
The nice thing about his solution is it is very simple code, and it does not prevent users from searching for other values. Frequently the desire to filter lookups is just desired as a convenience to the users, and there are certain scenarios where you want to still give them the option of selecting a value outside of the filter if they need to.
Check out his solution here: http://advantageworks.blogspot.com/2008/02/pseudo-filtered-lookup-dialog-in.html. The only change I made was I included the OnChange code also in the OnLoad, so that the lookup would be filtered when I opened an existing record.
If you need to have a filtered lookup that filters based on multiple criteria or that can prevent users from selecting other values, I would recommend that you consider a different solution, such as Stunnware's Filtered Lookups for MS Dynamics CRM 4.0.

Thank you for posting this. This was so simple and easy to apply and only took me about 20 minutes to get this filtered look up working properly. Is something like this possible for picklists also?
For example, I want to be able to filter available picklist options based on a value in another picklist.
Thanks!
Posted by: Hann | October 21, 2008 at 03:41 PM
If you wish to filter picklists, check out the free mscrm Demonstration Tools. it includes an awsome filtered picklist generator
http://www.microsoft.com/downloads/details.aspx?FamilyID=634508dc-1762-40d6-b745-b3bde05d7012&DisplayLang=en
Posted by: Joel Lindstrom | October 22, 2008 at 06:03 PM
What if you wanted it 3 tiered? example Area Category Issue?
Also what about zip? Is there a way to populate City and State with the Zip selected?
Posted by: David Withers | July 30, 2009 at 12:15 PM
Hi David,
If you want a more complex filtered lookup, like your area/category/issue, I recommend the filtered lookup product from www.stunnware.com. Michael has done a great job and this can easily handle that kind of logic, and it is the best thing out there for filtered lookups. The example in the post is not really good for that.
Regarding auto populating city and state based on zip, why not use a workflow?
1. Create an entity with postal code and the city and state associated with the postal code
2. Relate to account, contact, or wherever you want to use the postal code and remove the default zippostalcode field from the form.
3. Create a workflow that runs on create of the given record or on update of the postal code zipcode.
4. In your workflow, update the record city and state field with the city and state of the related postal code.
the only downside of this is that the change doesn't happen "before your eyes," but it will be there when you refresh the record.
BTW, with this approach, I usually also have the workflow update the system zippostalcode field so the zip code will be included in the outlook integration for contacts.
Posted by: Joel Lindstrom | July 30, 2009 at 12:52 PM