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:
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)
"*" indicates required fields