DUPLICATE_VALUE in Salesforce: what it means and how to fix it

Short answer: DUPLICATE_VALUE means you tried to save a value into a field that Salesforce enforces as unique, and another record in the org already has that value. The message names the field and the ID of the record that already holds it, so you can see exactly which existing row is in the way.

A custom field can be marked Unique when it's defined, and External ID fields often are. Salesforce then refuses to store the same value on two records of that object. Some standard values are unique as well, such as a user's Username. When a save would create a second copy, the API returns:

DUPLICATE_VALUE: duplicate value found: Customer_Number__c duplicates value on record with id: 001...

Unlike most errors, this one names both the field and the existing record, which makes the collision easy to inspect.

Why it happens

  • Reloading data that's already there. Running the same import twice, or re-running a partial load from the beginning, sends values the first run already stored.
  • Duplicates inside the file. Two rows in one CSV share a unique value. The first one saves and the second fails, which looks random until you sort the file.
  • Leftovers in the target org. A sandbox refreshed from production already holds records with those unique values, so copying the same records in again collides.
  • Soft-deleted records. Records in the Recycle Bin can still occupy their unique values.
  • Too few possible values. A unique field filled from a short list, a checkbox or a small picklist runs out of distinct values quickly.
  • Case-insensitive matching. ACME-01 and acme-01 count as the same value on a case-insensitive unique field.

How to fix it

  1. Check the existing record. Open the ID from the message. If it's the same real-world record, update it rather than inserting a new one.
  2. Upsert on an External ID. Matching on a stable key turns a would-be duplicate insert into an update.
  3. Deduplicate the source. Sort the file by the unique field and resolve repeats before loading.
  4. Clear the target first when you want a clean copy, and empty the Recycle Bin for the objects involved.
  5. Generate distinct values for test data, for example by adding a sequence or suffix to anything that must be unique.

How Syntharil handles it

Syntharil classifies DUPLICATE_VALUE as an org state error, since the clash is with data already present rather than with the shape of the value. When seeding, it tracks the values used for each field marked unique and adds a numeric suffix to any repeat, trimmed to fit the field length. That tracking covers the current job only; values already in the target org aren't checked, so a collision with an earlier load can still occur. It warns before a run when a unique checkbox or picklist has fewer values than the records requested, and a fixed value you set yourself on a unique field is sent as written. For replication, a full copy can clear the target objects first, and delta runs update records copied earlier by matching on the source ID stored in a Syntharil external ID field instead of inserting them again.

FAQ

How do I find the record DUPLICATE_VALUE is pointing at?

The message ends with the ID of the record that already holds the value. Paste it after your org's domain in the browser, or query it, to see the existing record and decide whether to update it instead.

Is DUPLICATE_VALUE the same as a duplicate rule?

No. DUPLICATE_VALUE comes from a field-level Unique setting and can't be bypassed. Duplicate rules are configurable matching logic and report DUPLICATES_DETECTED instead.

Does a case-insensitive unique field treat ABC and abc as duplicates?

Yes. Custom text fields marked Unique are case-insensitive unless the admin chose the case-sensitive option, so values that differ only in letter case collide.

Can records in the Recycle Bin cause DUPLICATE_VALUE?

They can. A deleted record still holds its unique value until it's permanently removed, so emptying the Recycle Bin, or hard-deleting the old rows, can clear a collision that seems to have no live owner.

Why does an upsert return DUPLICATE_VALUE?

An upsert matches on one external ID field, but the row can still carry a value for a different unique field that another record already uses. The match succeeds on the first field and the save fails on the second.

All Salesforce errors →

Try Syntharil free