The DUPLICATES_DETECTED  error can occur during a data deployment if you have defined a duplicate rule in your target org that blocks the creation of duplicate records.

What causes the error?

Matching rules compare one or more fields on a new record with the same fields on existing records and can be used in conjunction with duplicate rules to block the creation of new records and/or prevent the updating of existing records.

You may have activated a duplicate rule that blocks the creation of a new record if the values in certain specified fields match the values in fields on existing records. In these cases, Gearset’s data loader throws a DUPLICATES_DETECTED  error. 

How do I fix the error?

One simple fix for this error is to disable the duplication rule in your target org. 

Alternatively, for the purpose of the deployment, you could simply filter and exclude the record(s) that give rise to the error. 

In general, however, it’s best to use a single field with a unique value to determine whether a record is created, updated or rejected as a duplicate. Here’s where external IDs come in useful. An external ID within Salesforce is a custom field that contains a unique identifier, e.g. a product code, a contract number or a social security number. You can set a unique record identifier (or “upsert field”) from the Salesforce UI by selecting the relevant checkbox when you create a new custom field:

If your records include external IDs, Gearset’s data loader will create or upsert your records based on this unique identifier in the target org.

Did this answer your question?