Duplicate Rules
Learning Content
Last updated: July 21, 2026
Duplicate Rules
A Duplicate Rule is a Salesforce declarative feature that helps prevent or manage duplicate records by evaluating incoming data against existing records. It works together with Matching Rules to determine whether a record being created or updated is a potential duplicate.
Unlike Validation Rules, which validate whether the data itself is correct, Duplicate Rules determine whether the record already exists in Salesforce. Depending on the configuration, Salesforce can either block the save operation or simply warn the user while allowing the record to be saved.
π‘ LearnFrenzy Insight
Imagine checking into a hotel.
Before creating a new guest profile, the receptionist searches for your name, email address, or phone number. If your profile already exists, the receptionist avoids creating another record.
That's exactly how Duplicate Rules workβthey help Salesforce identify records that may already exist.
Where Do Duplicate Rules Execute?
User Clicks Save
β
βΌ
System Validation
β
βΌ
Before-Save Flow
β
βΌ
Before Trigger
β
βΌ
Validation Rules
β
βΌ
β Duplicate Rules
β
βΌ
Database Save
β
βΌ
After Trigger
Duplicate Rules execute after Validation Rules but before Salesforce permanently saves the record. If a potential duplicate is found, Salesforce follows the rule's configured action, such as blocking the save or displaying a warning.
How Do Duplicate Rules Work?
| Step | Description |
|---|---|
| 1 | User creates or updates a record. |
| 2 | Salesforce executes Validation Rules. |
| 3 | The associated Matching Rule compares the incoming record with existing records. |
| 4 | If a duplicate is found, the Duplicate Rule determines whether to block or allow the save. |
| 5 | If allowed, Salesforce continues the transaction. |
Matching Rule vs Duplicate Rule
| Feature | Matching Rule | Duplicate Rule |
|---|---|---|
| Purpose | Defines how Salesforce compares records. | Determines what action to take if a duplicate is found. |
| Comparison Logic | Exact or fuzzy matching. | Uses the Matching Rule result. |
| Blocks Record | No | Yes (optional). |
| Shows Warning | No | Yes (optional). |
| Works Alone | No | Requires a Matching Rule. |
Possible Duplicate Rule Actions
| Action | Behavior |
|---|---|
| Block | Stops the record from being saved. |
| Allow with Alert | Displays a warning but lets the user continue. |
| Report Duplicate | Logs duplicate information for reporting and review. |
Real Business Scenario
π’ Business Example
A company stores thousands of customer records.
When a sales representative creates a new Contact, Salesforce compares:
- Email Address
- Phone Number
- Customer Name
If a matching customer already exists, Salesforce displays a warning or prevents the duplicate record from being created, depending on the Duplicate Rule configuration.
Duplicate Rule vs Validation Rule
| Feature | Duplicate Rule | Validation Rule |
|---|---|---|
| Purpose | Detect duplicate records. | Validate business data. |
| Requires Formula | No | Yes |
| Checks Existing Records | Yes (through Matching Rules). | No |
| Can Warn Instead of Block | Yes | No |
| Best For | Duplicate prevention. | Business validation. |
When Should You Use Duplicate Rules?
| Use Duplicate Rules | Avoid Duplicate Rules |
|---|---|
| Prevent duplicate Leads | Business calculations |
| Prevent duplicate Contacts | Mandatory field validation |
| Prevent duplicate Accounts | Updating field values |
| Data quality management | Complex Apex processing |
| Customer master data | Cross-object automation |
π Behind the Scenes: What Happens Internally?
User Clicks Save
β
βΌ
Validation Rules Complete
β
βΌ
Matching Rule Executes
β
βΌ
Duplicate Found?
Yes β No
β
βΌ
Duplicate Rule Evaluates
β
βββββββββββββββββ
β β
βΌ βΌ
Block Allow with Alert
β β
βΌ βΌ
Stop Continue Save
Transaction Process
Notice that the Matching Rule performs the comparison, while the Duplicate Rule decides how Salesforce should respond when a match is detected.
β
Best Practice
Use meaningful Matching Rules, combine multiple fields when appropriate, and choose between blocking or warning based on your business process. Test duplicate detection with realistic data before deploying to production.
β οΈ Common Mistake
Confusing Matching Rules with Duplicate Rules. A Matching Rule only identifies potential duplicates, while a Duplicate Rule determines whether Salesforce blocks the record or allows it with a warning.
π― Interview Tip
Question: What is the difference between a Matching Rule and a Duplicate Rule?
Answer: A Matching Rule defines how Salesforce compares records using exact or fuzzy matching. A Duplicate Rule uses the Matching Rule result to decide whether to block the save operation, display a warning, or allow the record to be created.
π Quick Revision
- β Executes after Validation Rules.
- β Uses Matching Rules to identify duplicates.
- β Can block or allow duplicate records.
- β Helps maintain high-quality customer data.
- β Supports both exact and fuzzy matching.
- β Does not replace Validation Rules.
β‘ Next Lesson
In the next lesson, you'll learn about the Database Save Process, including what happens when Salesforce writes records to the database, when IDs are assigned, and how the transaction progresses before After Triggers execute.
Practice What You've Learned
Test your understanding with these practice exercises