Apply Custom Filter on Multi-Entity Lookup field

In this blog, we are going to discuss how we can apply a custom filter on multi-entity reference lookup.

There was a requirement, to restrict lookup data on From field on Email. From field has the data type of Party List which basically allows you to select a record from the users and queues table. Now, the requirement was to restrict the data in such a way where logged In user can see only the queues of which he was a member, and for the user's table only his record to be shown.

As per the requirement, I have to apply two custom filters on the form field for each entity. I never did this before. So, after a lot of research and development found that the solution was too easy. We just have to apply a addCustomFilter function twice(one for each entity). like this:

Now I know how I can apply the custom filter on Multi-Entity lookup. It could have done the job for me if my filter on entity was straight forward. But, In this case it wasn't solving my problem as it only works with the filter of the same entity whereas, for queues, I had to use a linked entity as we wanted to show the queues where a user is a member. 

To achieve this, you have two options. you can use either addCustomView or setDefaultView. If you have to go with low code then just create a new view on the queue and use the setDefaultView function otherwise you have the option to use addCustomView without creating a view. For me, I already had a view created for the requirement I went for setDefaultView.

View for the requirement:


And here is the Complete code:


And here is the Output:

Comments

Popular posts from this blog

Create a System Dashboard from a Personalized Dashboard

Check Webresource Dependencies on form

Open Windows Email App with To, CC and BCC information from Dynamics