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

Parent/Child Relationship in Dataverse...What am I missing?

This is my first attempt at a Dataverse App and it has not gone like I wanted. My scenario seems to be quite simple...I have a PARENT table and CHILD table. This is One-To-Many relationship similar to ORDERS and ITEMS (line items of an order). I'm making a canvas app (within Dataverse) and I'm missing the part of how to get these tables to be related. 

PARENT.ID...is the PK on the PARENT table.
CHILD.ParentID...is FK on the CHILD table. 

 

I cannot seem to join the PARENT table to the CHILD table on the "ID" illustrated above. With that said...I've moved on to building the canvas app with full intention of using the PATCH() to take the PARENT.ID and store it in the newly created CHILD record. The video's that I've watched using the ITEM attribute for the CHILD table in this example using CDS rather than Dataverse worked. 

What am I missing? 

 

 

2 REPLIES 2
Fubar
Solution Sage
Solution Sage

On the Child Table, you just create a new Field/Column that is of type Lookup, and then select the Parent Table in the respective list and hit save (the 1 to many relationship is automatically created behind the scenes).

CNT
Community Champion
Community Champion

@ChadBishop The way you have set up ID as the PK in your parent table and ParentID as the FK in your child table is the traditional way of doing relationships. In Dataverse this is called Lookups. But real relationships (1-many and many-many) are handled differently. Infact Dataverse does all the heavy lifiting (managing PKs, FKs etc.,).

To set up a relationship, you don't need a FK. You have to select the Parent table and then go to the relationships tab to set up the relationship,

CNT_0-1622181557640.png

In my example, I have a 1-many relationship between Event and Event Attendance (i.e 1 event can be attended ny many attendees). I don't have any FKs for this in the Event Attendee table. Dataverse will handle all this.

In your App, you will use Relate() and Unrelate functions to create/remove those relationships between records. You will access the related records using the dot (.) notation.

For example, If I have a gallery with the Events and I want all the Event Attendances displayed in another gallery, the items property for this gallery will be,

CNT_1-1622182173215.png

I don't need to do any Filter with PK, FH etc.,

 

Hope this gets you going!

 

 

 

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,607)