Relationships in Dataverse managed with Power AutomateRelationships in Dataverse managed with Power Automate

In Dataverse you can create relationships between tables, but how do you manage the relationships from a flow in Power Automate?

Relationships in Dataverse

In Dataverse there are a number of different type of relationships that you can create.

  • Many-to-one/Lookup
  • One-to-Many
  • Many-to-Many

Relationship examples

Consider the following tables:

  • Address
  • Car
  • Company
  • Person
Tables created in a solution
Tables created in a solution

Many-to-one relationships

If we created a relationship between the car table and the Person table called Main Driver. Then we would create a Many-to-one relationship (car being the primary table) or a Lookup. Lookup and Many-to-one relationships are the same thing.

Many to One
Many to One

Many-to-many relationships

If we created a relationship between car and the Person table called Drivers ( a car can have more than one drive but only one main driver), then we would select a Many-to-many relationship

One-to-Many relationships

One-to-many relationships are the same as Many-to-one relationships but with the primary and secondary tables reversed.

Relationships in Dataverse managed with Power Automate Microsoft Dataverse, Microsoft Power Automate one to many relationships

Relating records in Power Automate

To start this example I will create a flow that creates a record to my Car table and a Person record to my People table.

A flow that creates a car and a person
A flow that creates a car and a person

I can now use the relate rows action to link the car with the person through the Many-to-many relationship. That I use to register all the drivers of the car.

A flow that creates a car and a person and then relates the records
A flow that creates a car and a person and then relates the records

The Maindriver relationship however is not listed here.

Select the relationship in the relate rows action
Select the relationship in the relate rows action

If I however switch the update around and

Now I can select the Main driver relationship without any issue.

Relate cars with drivers
Relate cars with drivers

So the Relate with record needs to be referring to the table at the Many end of the One-to-Many or Many-to-one relationship.

As we connected Person 1 with Car 1 in the above action our Main Driver for Car 1 will be Person 1.

Drivers related to cars shown on a form in a grid with records
Drivers related to cars shown on a form in a grid with records

Using the relate action we can update our Many-to-Many relationship just the same way as we updated the Many-to-one relationship.

Relate Many to Many related records
Relate Many to Many related records

When I feed the above flow with Person 2 and Car 2, I will end up with a main driver and drivers set to Person 2.

Drivers related to cars shown on a form in a grid
Drivers related to cars shown on a form in a grid

The pains of relate rows

Hey, there is now SharePains.com post without a bit of a pain point. So far all worked well, but …

Recently I came across a bit of an issue with the relate rows action. My action was configured correctly.

Relationships in Dataverse managed with Power Automate Microsoft Dataverse, Microsoft Power Automate correctly configured relate action

As my flow was running there were no failures and the action reported its green tick telling me that all had worked as expected. But …

The relationship wasn’t updated. I’ve seen this once before. Using the Update a row action and specifying the relationship in the classic way, did work.

Relate actions using the Update a row action
Relate actions using the Update a row action
Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications Microsoft MVP working as the Head of Power Platform at Vantage 365. You can contact me using contact@sharepains.com

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains by Microsoft MVP Pieter Veenstra

Subscribe now to keep reading and get access to the full archive.

Continue reading