Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Subgrid records on entity's main form don't show in related records for its many:many relationship

Posted on 13 Nov 2024 21:30:12 by 80
I have an Action Items entity with a many:many relationship to itself. End users are requesting the ability to relate similar action items to each other, so when one item is completed, they can easily view others that should be marked as complete as well.
 
On the main form of Action Items, I have a subgrid that points to the Action Items table with a custom view (Related Action Items). show related records is checked. I can add existing action items to the subgrid as intended, but when I click on one of the records and open the main form of that record, the subgrid is blank (vs. displaying the related records from the previous screen).
 
One thought was to create an intersect table and using a flow, assign a GUID to related action items. 
 
For the flow's trigger, the relationship table name is not appearing in the Table Name drop down, so I added it as a custom value. I can see rows from the table, but on save, I get an error "Could not find table name".
 
I feel like I am overcomplicated this. Any suggestions would be greatly appreciated!
 
  • CS-24071844-0 Profile Picture
    CS-24071844-0 80 on 21 Nov 2024 at 14:57:47
    Subgrid records on entity's main form don't show in related records for its many:many relationship
    Thank you for the detailed explanation, Mark! 
  • Verified answer
    Mark Nanneman Profile Picture
    Mark Nanneman 324 on 16 Nov 2024 at 17:26:45
    Subgrid records on entity's main form don't show in related records for its many:many relationship
    I have a couple suggestions to consider before I go into a dissertation on N:N relationships ๐Ÿ˜

    1.  You might want to consider grouping your action items another way, perhaps using a 1:N or even N:N relationship with another table.  For instance, if an "Action Item" has a lookup column to a "parent' table record (perhaps a "Project" table or some such), you could easily display pending action items related to that Project in a variety of ways.   You could also insert a quickview form in your action item form that shows the project, and that project quickview form could have a subgrid showing other pending action items, etc.

    2. Additionally, if you have some sort of attributes on your action items that indicate they are ready to be reviewed and completed (date time column, choice column, etc), you can create a list view that just shows all of them in that state and users can work through that list.

    More on N:N relationships

    When you make an self-referential N:N relationship, there's directionality involved.  The table basically has a column for "Record One ID" and "Record Two ID", and the view in your record's subgrid is filtering on Record One = My GUID.  This is why you can add relationships from one record's subrid, but not see anything in the same grid when you click into one of the related records.

    There are a couple ways to visualize this, one you can click on the "Related" tab on your record in your Model-Driven App.  You'll notice there's two options for your N:N relationship--one is for the First Column, the other is for the Second Column.  If you toggle between these you'll see all the related items, whether the relationship is on column 1 or column 2.
     
    Example: Action Item B1 was added to Action Item A1, so it's on Column 2 and shows up on the 2nd Actions Items asscociated view.

    Two "Action Items" Associated Record Views under "Related", since the N:N is on the same table, there are potentially  records associated in Column 1, and records associated in Column 2 of the intersect table.
     


    You can also see this if you query the relationship table--you can do this in power automate by just putting the logical name of your relationship + "set" in a "List rows" action.
     
    e.g. 
    Here I created my own "Action Item" table with an N:N to itself and created some relationships.






     


    If you add 3 related Action Items to Action Item 1's N:N grid, each of those 3 are related to Action Item 1 but not each other, and they are only related as the 2nd record.  

    If you really wanted to be able to see all the related items whenever you clicked into one, you could consider creating an embedded power app that would show these in a gallery, or you could add some flow, plugin or script to auto create N:N relationship rows going the other direction whenever the initial N:N is created.  You would need to be careful to not make an infinite loop, depending on what method you used.


    If this helped you, please click "Does this answer your question" and give it a like to help others in the community (+ close the ticket)!

    Power Platform Developer | LinkedIn: Mark Nanneman | Blog: Power Stuff  | YouTube: Mark's Power Stuff  | Buy me a coffee

     
  • ronaldwalcott Profile Picture
    ronaldwalcott 660 on 16 Nov 2024 at 05:14:04
    Subgrid records on entity's main form don't show in related records for its many:many relationship
    Sorry I don't use model driven apps
  • CS-24071844-0 Profile Picture
    CS-24071844-0 80 on 15 Nov 2024 at 20:24:08
    Subgrid records on entity's main form don't show in related records for its many:many relationship
    @ronaldwalcott 
     
    When I click on a related record that has been added to the subgrid, the related record's main form subgrid does not show the initial record (the subgrid is blank).
     
    This is a model-driven app vs a canvas app - I do not have a gallery with properties for 'items' or 'onselect'.
  • ronaldwalcott Profile Picture
    ronaldwalcott 660 on 14 Nov 2024 at 06:20:43
    Subgrid records on entity's main form don't show in related records for its many:many relationship
    The intersect table should already exist within dataverse as that is how many to many relationships are configured.
    When you click on the record are you also showing its related records?
    Show the code for the onselects and the items for the galleries.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

October 2024 Newsletterโ€ฆ

October 2024 Community Newsletterโ€ฆ

Community Update Oct 28โ€ฆ

Power Platform Community Updateโ€ฆ

Tuesday Tip #4 How to Conntact Supportโ€ฆ

Welcome to a brand new series, Tuesday Tipsโ€ฆ

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,051

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,793

Leaderboard