Filtered lookups was an oft asked for feature in the yesteryears of Microsoft Dynamics CRM 3.0 and CRM 4.0 with a variety of solutions being offered and implemented to tackle it – all of course were unsupported. With Microsoft Dynamics CRM 2011, the guilty pleasure of custom hacking an unsupported solution to achieve filtered lookups and bragging about it has been denied by Microsoft. So instead I will blog about the out of box solution for filtered lookups in Microsoft Dynamics CRM.
Let’s take an example and work through it – suppose you want to have a relationship on the contact record that specifies the preferred shipping partner. But you also do not want all accounts to be displayed in the lookup which includes all types of accounts – in other words, you want the “Preferred Shipping Partner” field to be a filtered lookup to Accounts that displays only the accounts which have an account type of “Shipping”.
It all starts in the customization section under the setting area of CRM 2011. This is what you need to do:
- Navigate to Settings > Customization
- Launch the working Solution or if you do not have one, either create one or click on “Customize the System”
- Navigate to the entity for which you want to have a filtered lookup. Here we want Accounts to be filtered, so let’s go to Accounts
- Create a filtered view as per your criteria. Set the filtered criteria as “Account Type” equals “Shipping” and name the view as “Shipping Partner”. Of course if the field “Account Type” doesn’t exist, then you need to first create it before you can use it in the filter criteria!
The field Account Type has also been added to the columns. Use the “Add Columns” to add columns and “Edit Filter Criteria” to add the Filter as shown below.
- Navigate to the child entity, on which you want this filtered view to show up. This would be contact entity as per our example. We want the filtered account lookup to show on the contacts form
- Navigate to the Many-To-1 relationship to ensure that the relationship exists from the parent entity to the child entity, if it doesn’t then create one. We will create a Many-To-1 relationship with the Parent as Accounts and the Child as Contact and name the lookup field as “Preferred Shipping Partner”
- Navigate to the Forms section on the child entity and open the form on which you want to show the filtered lookup. We will open the Main Information form
- Add the lookup field to the Form. Just double click on the “Preferred Shipping Partner” to add it to the form.
- Double click on the field to launch its properties or click on the “change Properties” button in the ribbon.
- Click on Details tab in the Field Properties window and scroll down to “Additional Properties” and select the filtered view created for the parent entity as the Default view. We will select the “Shipping Partner” view which we created earlier for Accounts
- Save and publish your customizations
- That’s it! You are done.
Let take a little closer look at the options available in the ‘Additional Properties’ section:
- Display Search Box in Lookup Dialog – if you want to turn off search in the Lookup window, not a great idea especially if you have a lot of records in the view
- Default View – Select the view which will default in the lookup window, we have selected it to be the filtered view for our scenario
- View Selector – this will let you define which views are available in the Lookup window
- Off – The default view is the one and only view which is available, which is a great option, if you want to use filtered lookups and this is what we are using
- All – All views will be available. The user can select from any of the views if required
- Show Selected Views – You can choose which other views apart from the Default view would be available in the Lookup window. The user can change the view if required among the selected list of views
What other features in CRM 2011 would you like to get a more in-depth look at from the CRM Experts at PowerObjects?