I have a data cleaning scenario where I am trying to identify all contacts with a duplicate email address listed on another contact and merge the 2(or more)? Any way I can do this in mass?


There's no "out of the box" way to do this en masse. There are tools out there on the AppExchange that can do this for you, the Duplicate Rules feature can help you prevent duplicates, or you could build your own tool, such as a Batchable Apex class that sweeps over your database and merges duplicates. Just keep in mind that merging duplicates by email alone might not be preferable in all cases. Personally, I'd recommend that you go with an app if you don't have a lot of experience or time to build your own solution. This is something that's already been solved, and that you can leverage for a nominal cost.

  • Never tried batchable apex but at this point might as well do it, Thanks – Rufus K. Sep 14 '16 at 6:24

I've been doing the same thing recently. Personally I've been exporting data with the data loader including id's - doing Vlookups in excel and tagging duplicates then when I update back into SF run a report on the duplicate tag so they say "Duplicate" in the company/contact name for example and then from there I can decide if I delete or merge etc. Sure there are faster ways but this was the easiest for me

Good luck with it :)

  • About 2-3 months ago, I was helping out my intern who was using this method (export with Data Loader, work in Excel to detect duplicates). Instead of vlookups, we relied on sorting by a couple of columns so that all the John.Doe@company.com ended up in a contiguous block of rows. Detecting duplicates was then a simple formula of "Look at the row above, do columns a, b, and c match? then isDuplicate, else isOriginal". We also used formulas to merge data from the duplicates to the original in cases where the original record's field was null. – Derek F Sep 9 '16 at 14:19
  • Both work but if Vlookups are used effectively enough the process is sooooo much quicker. Either way - Salesforce Apps probably provide a more UI friendly less formula dependent solution - it's just about learning software in that case though, so more beneficial for the future but if you want something done immediately then Vlookups are the king of problem solving :) – Paul Rogers Sep 9 '16 at 14:51
  • Out of curiosity, how many rows were you working on? My intern and I had ~29,000 Contact records to sort out (and I think around 8k were duplicates). – Derek F Sep 9 '16 at 15:02
  • 329k contacts - if you can match two fields so like if "JohnDoe@company.com" & Country "USA" then you can use the "Highlight Duplicate" & "Remove duplicate" functionality on excel as well. I had about 46k duplicates and managed to get most of them but it really can be tricky. Can also highlight the duplicates and then filter on the colour which is similar to your method but again, this makes excel do the majority of the work. – Paul Rogers Sep 9 '16 at 15:05
  • Thanks Paul and Derek, I have 26000 and neary 4000 dups. I can't delete them because some of these duplicates have related records so it's safer to merge the contacts so that no child records are lost. Contact merge on Salesforce works 3 contacts at a time until I find a better solution – Rufus K. Sep 14 '16 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.