How to Filter Lookups Without Custom Code in Dynamics 365 Customer Engagement
By Zackary Harwood, Solution Architect, Arbela Technologies
In Microsoft Dynamics 365 Customer Engagement, you may encounter a need to filter records available in a lookup based on other information on the form. Filtering lookups for 1:N and N:N relationships can be achieved without custom code by updating Related Records Filtering under Field Properties for the desired lookup.
For example, on Work Orders in Field Service adding a contact lookup is useful for capturing the individual who requested or needs to be contacted for this service event. By default, this contact record would show all contacts available; however, we can filter this contact lookup just like the Opportunity contact lookup is filtered based on Account.
To demonstrate, I created a custom lookup to contacts on Work Order and enabled filtering by updating the Field Properties > Related Records Filtering to Only show records where Service Account (Work Orders) Contains Company Name (Accounts) (Contacts).
After saving the changes and publishing, the field on the form will now only show contacts that are related to the Service Account on the Work Order.
Figure 1: Pre-Filtering
Figure 2: Post-Filtering
Figure 3: Contacts Related to Service Account
Filtering a lookup improves customer experience and data cleanliness by minimizing the options available for selection. Here are a few items to consider when implementing filtered lookups:
- Create a business rule to lock the filtered lookup until the related lookup is populated (contact is locked until the account is populated) so users cannot select contacts outside of the configured filter
- Create a business rule to clear the filtered lookup if the related lookup is cleared
- Under Field Properties > Field Behavior, disable "most recently used items for this field" on the lookup being filtered because as of Build 188.8.131.5252 the recently viewed list does not adhere to the filtering configured in Field Properties
Need some assistance? Contact us and we'll be happy to help.