Associate and disassociate table rows using the Web API
Article
You can associate individual records in table rows with other records using relationships that exist between the table definitions. In OData, the relationships are expressed as navigation properties.
You can discover which navigation properties exist in the $metadata service document. See Web API Navigation Properties. For existing Dataverse tables, see the Web API EntityType Reference, for each entity type, see the listed single-valued and collection-valued navigation properties.
The following table describes the three types of relationships between tables in Dataverse.
Type
Description
Example
One-to-Many
One record can have many records associated with it.
An account record can have many contact records in the contact_customer_accountscollection-valued navigation property.
Many-to-One
Many records can be associated with one record.
Many-to-One is the mirror image of a One-to-Many relationship. There's just one relationship.
Multiple contact records can be associated to a single account record using the parentcustomerid_accountsingle-valued navigation property.
Many-to-Many
Many records can be associated with many records.
Each security role (role) might include references to the definition of a systemuser. Both of these tables have a systemuserroles_associationcollection-valued navigation property.
Using single-valued navigation properties
For existing records on the many side of a one-to-many or many-to-one relationship, you can associate the record by setting a Uri reference to the other record. The easiest and most common way to do this is to append the @odata.bind annotation to the name of the single-valued navigation property and then setting the value as the Uri to the other record in a PATCH request.
Associate with a single-valued navigation property
For example, to associate a contact record to an account using the parentcustomerid_account single-valued navigation property:
When disassociating in this manner, you don't need to include the @odata.bind annotation. You can simply use the name of the single-valued navigation property:
With OData, both sides of a many-to-many relationship have collection-valued navigation properties. For one-to-many and many-to-one relationships, the table one the 'One' side has a collection-valued navigation property. There's no difference how you work with any of these types of relationships while using collection-valued navigation properties. This section describes how to work with collection-valued navigation properties with any type of relationship.
Add a record to a collection
The following example shows how to add a contact record to the accountcontact_customer_accounts collection, which is part of a one-to-many relationship.
The following example shows how to remove a contact record to the accountcontact_customer_accounts collection where the contact contactid value is 00aa00aa-bb11-cc22-dd33-44ee44ee44ee.
Demonstrate the use of Microsoft Power Platform solutions to simplify, automate, and empower business processes for organizations in the role of a Functional Consultant.