Hi,
I'm using a many to many relationship in CDS tables where Accounts can have multiple Proposals and Proposals can have multiple Accounts. I've been using this example here for relate and unrelating functions which is great but has some limitations.
I'm trying to replicate the experience you get in a model driven form in CDS - on a main form you can go to a subgrid connected to the current selected record and add or remove many-to-many record instantly just by clicking a button. It seems much, much more complicated in a canvas app!
I'd like to make sure that the user is only working on the proposal record they have just created from the previous screen (I can't trust them to pick the right one themselves in a gallery) and relate accounts only to this proposal. Then clear the galleries when they move to the next screen.
So I have two galleries: Gallery1 (Items: Proposals) and Gallery2 (Items: Gallery1.Selected.Accounts). I have a button that relates account records to Gallery2 from a combobox using Relate( Gallery1.Selected.Accounts, ComboBox1.Selected ) .
If I try to filter Gallery1 proposals by using a variable created in the last screen (varProposalID) Gallery2 will not show any data when it's in edit mode.
If I sort Gallery1 proposals by last created Sort('Proposals','Created On',Descending) it will show Gallery2 in edit mode, but I'm having problems clearing these galleries when users exit the screen. I'm also nervous the user could end up in the last record created- but it may not be necessarily theirs. I've tried a collection with a filter in OnVisible for the screen against Gallery1 but it stops Gallery2 appearing in edit again.
I've also got a revenue total from Gallery2 Text(Sum(Gallery2.AllItems,'Revenue'),"[$-en-GB]£#,##0.00") for all the accounts I've related which I sum and patch back into the newly created proposal record when the user navigates to next screen.
I don't know if I'm just taking a poor approach here and I should be using a form instead of Gallery1 for my newly created Proposal (as I only want to see and link all Gallery2 accounts to one proposal record at a time) but I can't see how I reference that form in Gallery2 items to make the many-to-many connection and still use the relate function.
Can anyone help please?
Thank you.
I believe I had someone reach out to me with a similar question - of allowing creation, deletion etc. of many-to-many relationships.
Here is my use case: a user can belong to more than one team, a team can have more than one user, an account can be related to many users. Here is what my canvas app does:
Attaching a small clip here, let me know if this is what you are looking for.
---
If you like this reply, please give kudos (Thumbs Up). And if this solves your problem, please mark this reply as a solution by selecting Accept as Solution. This makes it easier for others to find answers to similar questions.
Thanks!
Hardit Bhatia
Microsoft Business Applications MVP
Microsoft Certified Trainer MCT
Blog | Twitter | LinkedIn | Facebook | YouTube | Email
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
191 | |
45 | |
45 | |
38 | |
36 |
User | Count |
---|---|
261 | |
83 | |
82 | |
69 | |
69 |