One of the most common asks when using CDS as Data Source in a Canvas Power Apps is – How do I get the data from N:N entities?
Well, I’m attempting to explain this in the easiest way possible.
Let’s assume Account entity has an N:N relationship with Account Plans entity
Account <–N:N–> Account Plans.
And in Dynamics 365, you simply add these records by going into related records and adding them using Add Existing button
And now, you want to access this data for a record in a Canvas Power App? Correct? Let’s get going with it.
Enable the Entities involved
In this example, the entities involved are Account and Account Plans
- Accessing data for N:N entities require the entities to be enabled for Change Tracking. Let’s check that in CDS
- And also the same thing for Account Plan entity as well
Reading Data in a Canvas Power App
I’ve kept the presentation of my Canvas Power App very crude, please excuse me for that.
Scenario: Now, let’s say you want to see the N:N data on selection of a record i.e. on selection of Account, you want to see what all Account Plans are added to that Account.
- Now, to demonstrate this, I’ve taken 2 galleries i.e. AccountGallery to show list of Accounts
- And probably a list to just display what Account Plans are added (You can have any other control depending on what you want to do with these records). I’ll call the table AccountPlansTable
- And my formula to display the N:N records will be –
- Now, you’ll need to add what fields should be shown from Account Plans entity to identify the records. Well, obviously, Name field is the most relevant here.
I’ll click on Edit Fields for the AccountPlansTable
- And add the name field from that entity
- Once this is set, my App is ready to run
Accessing the N:N records
Let’s run the app and see how we can read these N:N records
Once I click on ABC/1/2&3, I can see the related N:N records in the DataTable below
Here are some more posts you might like –
- Create your first PowerApp! Connect to SharePoint Online List
- Dynamics 365 Solutions’ New Experience in Power Apps, Solution Checker and more
- AutoNumber field in CDS | PowerApps
- Sending Image from Canvas PowerApps to SharePoint Document Library using Flows
Hope this helps!!