cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Flowme
Frequent Visitor

Define Entitiy Relationships in Canvas App

Hi Guys,

 

does anyone have some experience on the following topics?

  • Write the “GUID” of an m:n relationship between 2 entities with a patch function in the canvas app:
    We submit a new form and want to patch the “GUID” of the last submitted form in a new record of another entity.

How can you define and write relationships (many to many) in CDS?

 

  • Access Teams (Dynamics)
    How can you add or remove Users from “Access Teams” (Dynamics) via a Canvas App?

Thanks

2 REPLIES 2
Drrickryp
Super User II
Super User II

Hi @Flowme 

I prefer to handle M:M relationships by creating a junction table as a separate entity.  Then, I can address the one to many relationships from either side of the junction table. This approach has the advantage that I can add additional fields to the junction table.  A feature that cannot be done using the "built in" relationships created by CDS.  https://powerusers.microsoft.com/t5/News-Announcements/Relational-Database-Principles-and-PowerApps-...  has an example of the junction table in a paradigm of Students and Classes with the additional feilds that would most appropriately be found in each table. 

EricRegnier
Super User II
Super User II

Hi @Flowme,

To create a many-to-many (N-N) relationship you have two options in CDS:

  1. Out-of-the-box N-N. Here are the steps: https://docs.microsoft.com/en-us/powerapps/maker/common-data-service/create-edit-nn-relationships-po...
  2. Like @Drrickryp mentioned, a custom N-N with a junction entity which could give you more flexibility.

To create/update the record and relationships, it is fully supported with the CDS Web API which is what the Connector uses. Here's more details this and suggest to have a quick read: https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/create-update-entity...

 

For you 2nd question, members of Access Teams are just user records. To add/remove, all you need to do is create/delete the membership record for that Access Teams. There are two API operations to achieve this:

Add: https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/addusertorecordteam?view=dy...

Remove: https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/removeuserfromrecordteam?vi...

Hope this helps!

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,182)