Automatic Duplicate Account Merge in Dynamics 365 Sales with Power Automate

Automatic Duplicate Account Merge in Dynamics 365
with Power Automate

In Dynamics 365 Sales, duplicate detection exists but only works at an individual level, for example, when a lead is converted or a new account is created.

Unfortunately, there’s no out-of-the-box solution to automatically detect duplicates in bulk across the system. This limitation can lead to data inaccuracies, especially as your organization grows.

To overcome this challenge, I created a Power Automate flow that finds and merges duplicate accounts automatically.

In this article, I’ll walk you through how to create this flow, and you can adapt it for your own needs.

Flow overview:

(Apologies, I have not renamed some of the foreach and conditions, but I think you will understand 🙂 )

Step-by-Step Guide to Creating the Flow

Step 1: Set up the Trigger

The first step is to set up the trigger for the flow. We want this flow to run on a regular schedule to detect duplicates. Use the Recurrence trigger to specify how frequently the flow should run (e.g., daily or weekly).

Step 2: Query Accounts from Dataverse

Next, add an action to list all accounts from the Dataverse. This will retrieve all active accounts so that we can compare them and detect duplicates.

  • Action: Use List Rows from the Dataverse connector.
  • Filter: You can filter for only active accounts or specific criteria that make sense for your business.
  • Also initialize the variable Duplicates here as an array

Step 3: Identify Duplicate Accounts

Once the accounts are retrieved, you need to compare the names or other unique fields to detect duplicates.

  • Use a loop to go through each account and check for duplicate names.
  • Clear the array variable Duplicates
  • Implement a condition in the flow to identify if two or more accounts share the same name.

The Replace() is used to fix the acounts that have the character inside their name, to not break the odata filter.

Condition:

and(greater(length(outputs(‘List_rows_2’)?[‘body/value’]), 1))
If any duplicate is found (YES under condition), add the Account ID to the Duplicates array

Step 4: Merge the Duplicates

Once duplicates are identified, use Dataverse’s Unbound Action to merge the duplicate accounts. The unbound action allows you to merge records within Dataverse without having to handle the data manually.

  • Action: Use the Perform Unbound Action step from the Dataverse connector.
  • Target: The original account and the duplicate account.

Condition 3: (meaning one or more duplicates have been found)

length(variables(‘Duplicates’))
If YES, then take the first and the last account:
(Because you can only merge 2 accounts at the same time)
Get the first Account:
Get the last duplicated account:
Send me an email notification, and then do an Unbound Action (Merge):
That’s it, our entire flow is ready:
AccessOrange is a leading Microsoft Partner that specializes in Microsoft 365, Dynamics 365 and Azure to help our customers work smarter.
If you need help with building this flow in your own environment, leave your contact information below, and we will contact you as soon as possible.

"*" indicates required fields

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
This field is for validation purposes and should be left unchanged.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

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