We already have loads of prior duplicate data in our salesforce.com records. Say close to 5000 among 100000 records . Our new requirement states to prevent any new data being saved as another duplicate to 100000 ones that are already existing. I tried using a workflow, but only duplicate data to ones created after the work flow is getting prevented, isn't working for the ones prior. Also we have fields A and B to be jointly unique for this to be a duplicate.

Suggestions are welcome.

  • Preventing duplicate data is hard; I'd suggest a 3rd party tool. – Mike Chale Sep 18 '13 at 12:44
  • Agree with Mike. Demand Tools has a great Dupe Blocker – Chris Duncombe Sep 18 '13 at 12:51

You will have to update the field that is a composite of A and B using the Data Loader to get your data into a consistent state. Once the records are properly uniquely indexed, all future operations will be taken care of.


Couldn't you run a query similar to this:

listOfConflictObjectsInSystem = [SELECT Id,Field_A__c,Field_B__c FROM ObjectName n WHERE n.Field_A__c = :objectToAdd.Field_A__c AND n.Field_B__c = :objectToAdd.Field_B__c];

(sorry for formatting I could not find the salesforce code styling tags)

Checking the size of 'listOfConflictObjectsInSystem' will tell you if any objects are already in the system containing the data from those two fields. As long as these are uniquely identified.

If the combination of the two added together make it unique then create a formula field on the object that combines the two fields and query off of that field.

I have done this in a few of the systems - sending the list of objects in conflict to a visual force page and giving the user adding the record a page showing all the duplicates found for the object they want to add. I also add in functionality for this to be overridden in certain cases.

If you are trying to deduplicate the records already in the system than a data loader will need to be used - like sfdcfox already stated.

  • Hi Chris, my concern is to prevent any new records from saving with duplicate values to ones already existing in the system. The existing duplicate records are not an issue in the business requirement. Just the new records should not match any values from existing ones. I tried updating the field through code, but since existing records already have have duplicates, its a concern, and update is failing. – Subham Sep 19 '13 at 6:37

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