Quick Tip: Finding the Right Many-to-Many Relationship When Adding Subgrids

When you add a subgrid to a model-driven app form and select "Show related records", you'll see a list of tables related to your current form's table.


For one-to-many (1:N) child tables, life is pretty straightforward. The lookup column name appears at the end in brackets, making it easy to distinguish between multiple relationships with the same table.

But many-to-many (N:N) relationships? That's where things get messy. The dropdown just shows the related table name, and if you've got multiple many-to-many relationships with the same table, good luck figuring out which option corresponds to which relationship.

Here's a quick workaround that's saved me plenty of headaches:

1. Click the ellipsis (...) at the top and select "Switch to Classic"

2. In the classic form designer, open the subgrid properties (by selecting the subgrid and click Change Properties)



3. Fire up your browser's Developer Tools (F12 or Ctrl+Shift+I)



4. Click the "select element" button in Developer Tools (or press Ctrl+Shift+C)



5. Point to and select the Entity dropdown in the "Specify the primary data source for this list or chart" section


6. Expand the <select> tag in the HTML inspector

You'll now see all the options with the actual relationship names sitting right next to each entity name. From there, you can work out exactly which relationship name matches the subgrid you want to configure (say, the second Contact in the list) and choose the correct one from the dropdown.

Not the most elegant solution, but it gets the job done when you're dealing with multiple N:N relationships to the same table.

Comments

Popular Posts