
Announcements
Hi Community,
I have a scenario involving N:N relationships and need some advice:
Now, when I use the “Add Existing” option to associate XYZ records with ABC, I want the lookup to only display those records that are linked to the same Contact associated with the ABC record.
Is there a recommended way to filter the lookup this way? Any references or advice would be greatly appreciated!
hanks for the detailed scenario—this is a common challenge when working with N:N relationships in model-driven Power Apps or Dynamics 365.
To summarize your setup:
To filter the lookup in the “Add Existing” dialog, you’ll need to use a custom JavaScript web resource with a custom filter on the lookup field. Unfortunately, out-of-the-box filtering for N:N lookups in the “Add Existing” subgrid is limited, but here’s how you can approach it:
Here’s a simplified example of how the JavaScript might look:
You’d register this function on the OnLoad event of the form and possibly on the OnChange of the Contact field.
If you want to keep the N:N relationship but need more control over the selection process: