Duplicate data is an issue many of us are familiar with. Dynamics does have methods to detect duplicates as they are being created and ways to use rules to gather potential duplicates after the fact. However, someone still needs to go through that list and determine if they should be merged one by one. Now if you have thousands of duplicates to go through that can make for a time-consuming task. So, how do we list duplicates and merge them in one process? One solution would be to use Power Automate.
What is Power Automate?
Users can create automations between services and applications with Microsoft Power Automate. Users can create automated processes that replace time-consuming or repetitive activities. Specific events can be set at a trigger for these types of automation.
Setting up the Flow
Before we get started on the flow, we are going to need a way to let us know when a record has been merged so we only run the process once per set of duplicates. We can solve this by creating a yes/no column on the table we are merging. Now that we have that column we can start on the flow. The first thing we need is a list step that lists all records that we are interested in merging. We can use an Odata filter or FetchXML. Keep in mind the way we sort this list step will determine the Primary record for each set later on.
Next, we need to use an apply to each step for each record in the list. The first thing we'll need to do here is create a get record step to grab a fresh copy of the record we are on to see if the merged column is set to yes or no. If it's set to no, we can go ahead and end this loop. If it's set to yes, we will want another list step that lists all records that match the record in the initial loop. The logic here would be similar to how duplicate detection rules are set up out of the box. (