Ever wondered whether its possible to filter a lookup on a model driven app form based on a previous lookup on the form you’ve already populated? It’s possible! Want to know the good part? We don’t have to use anything complex like custom JavaScript or anything to achieve this! In this blog post, I’ll show you how to configure forms to support this kind of cascading filter! 🤩
A simple scenario
Let’s look at a simple, and very common scenario! I’ve got a table where I log customer issues. This is similar to the Case table in Dynamics 365, but I’ve built a much more simplified and basic version. On my customer issue record, I need to be able to store both the account which is my customer, and a relevant contact at that customer. I want both pieces of information explicitly and in separate fields.
Once I’ve selected the account / customer the issue is for, I want the lookup of contacts to be filtered down to only show contacts for the account I’ve already selected.
Let’s see how we can achieve that.
Form
Let’s start by taking a look at a form I have for my table. Very simply I’ve got four fields including a name for the issue, a description, and then I’ve got my account and contact fields to relate this to my customer and a contact at their organisation.
In the form editor, I’m going to select the three dots in the ribbon and select switch to classic.
Now in the classic form editor I’m going to double select the contact field which is the one I want to filter based on the account selected.
Now I’m going to scroll down and focus on the related records filtering section of the field properties dialogue.
I’m going to select the checkbox to enable filtering, then I’m going to select the field that I want to base this filter on (account) in the top dropdown, and in the second I’m going to select the view/relationship I want to use.
Now I have the option to let my users turn off the filter, and finally I’ll select ok.
Before you close the tab, ensure you save and publish your changes to see them reflected in your form.
Testing it out!
Now let’s see the changes in action. First I’m going to select the contact input on my form and see what suggestions I get. You can see I get contacts appear from my table without any filter currently.
Now I’m going to select an account. I’ll select Microsoft and I should now only see Microsoft contacts in my contact input.
And there we go! Check out the filtered lookup!
Did you like this post?
Well that’s a wrap on this blog post! Thanks for checking out my content. If you liked this post, be sure to check out a few others, and if you’re still enjoying the reads, be sure to subscribe to my blog to get my posts directly in your inbox! 📥
Subscribe