How to merge Dataverse records

This blog will show you how you can use the Perform an unbound action to merge two Microsoft Dataverse records within a Power Automate flow. In this example I will use two records from the Accounts table from Dynamics 365 Sales.

Inspiration

I was triggered by the comment from ChrisWP below.

I am trying to use “Perform an unbound action” in a Power Automate to merge two contact records and struggling with the parameters required.

Power Users Community thread: Perform an unbound action – Merge – How to use.

Merging records is always an interesting scenario and also a great reason to look into the details of the Perform and unbound action.

Interface clue

If you want to know how a merge action works it is a good idea to go to the interface first. When you merge two records in the interface you will get a dialog like below.

mergeaccounts
As you can see you can select a target and you can specify which fields you want to keep. This is useful to know for the Power Automate action configuration.

Flow setup

mergeaccounts_flow

1. Add a Manually trigger a flow trigger action.

2. Add a Get row by ID action. Use the Account GUID to retrieve the first account record. This will be the Target record.

getaccount01

3. Add another Get row by ID action. Use the Account GUID to retrieve the second account record. This will be the subordinate.

getaccount02

4. Add a Perform an unbound action. Select the Merge action. Use the configuration of below.
In the action you have the same type of configuration as in the interface. You can specify a target and a subordinate. And you can specify which fields you want to update. In the example below we are only updating the name.

Also notice the double @ characters before the odata.type field. This is to escape the single @ character and make the json valid.

performunboundaction

Testing the merge

When you run the flow you should get a result like below. As you can see subordinate is deactivated and there is a notification that it is merged into the target record.

subordinatetestresult
Happy testing!

You may also like...

5 Responses

  1. Anthony P says:

    Will this process wort with custom entity data? I would assume so since its dataverse records, right?

  2. Dennis says:

    Hi Anthony,

    Unfortunately, the merge feature (also in the interface) is only available for the Account, Lead & Contact tables/entities :
    https://docs.microsoft.com/en-us/power-platform/admin/detect-duplicate-records

    Rule of thumb, if you can merge it in the interface you can merge it via this Dataverse action 🙂

  3. Anthony P says:

    Thanks Dennis! That is what I figured 🙂

  4. Fernando Suarez Ornani says:

    Hi Dennis!
    What if:
    a) I have 30 fields to merge
    b) I want to do some logic: 1) keep the field of the entity with data; in case both have data, keep the newer
    I saw you mentioned using ‘collection functions’. How can I achieve this?

  5. Dennis says:

    Hi Fernando,

    If you want to merge 30 fields that would probably be very challenging task in a Power Automate cloud flow.

    Have you considered a data flow instead? My suggestion would be to have a look at one of the Microsoft Fabric components instead for this.

Leave a Reply

Your email address will not be published. Required fields are marked *

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