error

DUPLICATE_VALUE: duplicate value found

What does this error mean?

This error occurs when Salesforce detects that a value being inserted or updated already exists in another record where the field is marked as Unique or protected by a Duplicate Rule.

Examples include duplicate email addresses, duplicate external IDs, or fields configured as unique in Object Manager. Salesforce enforces these constraints to maintain data integrity. [oai_citation:0‡Clientell](https://app.clientell.ai/salesforce-errors/duplicate-value?utm_source=chatgpt.com)

Common Causes

1. Unique field constraint

A field marked as Unique already contains the same value on another record.

2. Duplicate rule blocking insert

Salesforce Duplicate Management rules prevent inserting records with matching values.

3. Duplicate External ID

When using upsert, multiple records contain the same External ID value.

4. Duplicate records in the same transaction

Multiple records being inserted together contain the same value in a unique field.

How to Fix It

Solution 1 — Check existing records

SOQL

SELECT Id, Name
FROM Account
WHERE External_Id__c = '12345'

Solution 2 — Use UPSERT instead of INSERT

Apex

upsert accounts External_Id__c;

Solution 3 — Review Duplicate Rules

Navigate to:


Setup → Duplicate Rules
lightbulb

Pro Tip: Always use External IDs for integrations. They allow safe upserts and prevent accidental duplicate records.