Tuesday, September 11, 2012

MSCRM 2011: Lookup Filtering Based on Another Lookup

A Client recently asked ‘Can I filter the choices in a Lookup based on the value selected in another Lookup field?” The answer is “Yes”. CRM 2011 now includes filtered Lookup fields.

In the example below, I will show how to filter the “Responsible Contact” Lookup on the Case form to only include the contacts associated with the selected Case account.
In “Settings”, “Customization”, “Customize entities”, choose the Case Form.
On the Form, select the “Responsible Contact” field.
By clicking the “Change Properties” button, you will see the field properties for the “Responsible Contact” Lookup field.

Under the Related Records Filtering section of this form, check the check box “Only show records where”. This will filter the available values of this Lookup field to records related to the value selected in another Lookup field. Choose the “Account (Accounts)(Cases)” in the top drop down box. In the “Contains” choose “Company (Accounts) (Contacts)”. This will only show the Contacts that are related to the Account chosen in the Customer field above.
Please note that you can also select whether or not to allow users to turn off the filter—this gives the  user  the ability to choose whether a filter is “hard,” limiting users to just the filtered records, or “soft,” allowing users to select something outside of the filter. This is important because some filters are there to prevent users from selecting invalid record combinations, while others are there for user convenience, but may need to be overridden for exceptions.
This works well for straight-forward filtering of Lookups but for more complex instances, java script might still be required to remove values from the second Lookup.