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
Super User
Super User

@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
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (3,755)