You need to sign in to do that
Don't have an account?
Sam111
Batch Class - Delete Duplicate records
We have a custom object and around 2 million records. We would like to do a clean up on duplicate records. Like if they have same name, same email, opt out flag etc. I would like to create a batch class to delete the duplicate records and just keep one record.
For ex:
Record1: Name = Name1 Email = name1@name.com opt out = true created date 01/01
Record 2: Name = Name1 Email = name1@name.com opt out = true created date 02/02
Record 3: Name = Name1 Email = name1@name.com opt out = true created date 03/03
I woul dlike to delete 2 records and keep the most recent created date record. So in this case, delete Record 1 an dRecord 2 and keep Record 3
Can someone help with this batch class? I appreciate your help!
For ex:
Record1: Name = Name1 Email = name1@name.com opt out = true created date 01/01
Record 2: Name = Name1 Email = name1@name.com opt out = true created date 02/02
Record 3: Name = Name1 Email = name1@name.com opt out = true created date 03/03
I woul dlike to delete 2 records and keep the most recent created date record. So in this case, delete Record 1 an dRecord 2 and keep Record 3
Can someone help with this batch class? I appreciate your help!
Try below App to clean your duplicate reocrds and keep the recent or you can merge it.
https://appexchange.salesforce.com/listingDetail?listingId=a0N300000058vzKEAQ (http:// https://appexchange.salesforce.com/listingDetail?listingId=a0N300000058vzKEAQ)
hope it will help you. or if you really wanna use Batch apex let me know.
Thanks
karthik
We've had to deal with something similar. What you can do is create a map of whatever your duplicate measure is (ours is email), to a list of all records that contain that email. Select your emails through an aggregate query where the count of emails is > 1, build a list of those. After your list is complete, select 200 of those at a time and eliminate them via the mapping discussed earlier.
Let me know if you have any questions!
Thanks!
-Sean