How to Filter Lookups by Related Records in Dynamics 365

Dominic Jarvis, 19 October 2017

In Microsoft Dynamics 365 when designing lookups on forms, it may be that you only want the user to be able to select certain records.

An example of the sort of functionality I mean is the Primary Contact field on an Account. Out of the box, this field filters contacts so that the user can only select Contacts that are associated with that Account.

It is possible to implement similar functionality to this manually and in a supported manner, with NO custom JavaScript.

In the example below, I will implement this in a very similar situation. In this example, I have a Venue, which may be owned by an account. If there is an account selected on the form, the contact lookup will be filtered by this so that only contacts associated to this account can be selected.

Using the Form Designer

It is quite easy to enable this functionality in Dynamics 365. On the form designer for the desired entity, select the lookup that you wish to apply the filtering to, and click ‘Change Properties’ (located in the home tab of the ribbon).


Figure 1: Applying Related Records Filtering to a lookup

In the section ‘Related Records Filtering’, I am able to select that I want the lookup to be filtered so that the Parent Account of the Venue is the same as the Company Name of the searched Contact.

This filter can also be applied so that the user cannot remove it, which is ideal in some situations, but in other situations, it may be appropriate to give users the freedom of choice.

The outcome of the filtering is shown below:


Figure 2: Pre Filtering


Figure 3: Post Filtering – Only contacts associated to the Parent Account of the Venue are shown.


Figure 4: Contact's associated to A. Datum

As shown above, only contacts associated to A. Datum are available. This is just a simple use case, and there are more filtering options available.

In addition to this, so long as there are additional views available and the “Users can turn off filter” checkbox is checked, it is possible for the user to remove these filters, or change the view to present a different set of records for the lookup. This can be done by clicking the “Look Up More Records” option when expanding the lookup.


Figure 5: Expanded Lookup

The other way to filter a lookup in an out of the box manner is to change the available views for the lookup. Custom views can be added and specified for a lookup in Dynamics 365, which allows for a greater degree of specification and versatility when displaying options for a lookup. In this example, we have a requirement to only allow a user to select accounts for the Venue to be accounts that they own. To accomplish this, we can change the Default view on the Lookup to be ‘My Active Accounts’, which allows the user to only see active accounts that they own.

Here I have also modified the “My Accounts” view, to show the owner.


Figure 6: Applying filtering via a view to a lookup


Figure 7: Pre Filtering


Figure 8: Post Filtering

The point of difference here lies in the fact that we are using a different view. With lookup fields, the first three fields from a view are displayed on the retrieved data, which allows you to more minutely customise the data that is displayed to the customer, giving them more relevant information to make their selection with.