Overview
Merging Leads in Salesforce removes duplicate Lead records and consolidates selected information into a single master Lead. The process preserves important related data (activities, tasks, events, etc.), deletes the losing records (they go to the Recycle Bin), and triggers the same automation and Apex behavior as a combination of update and delete operations. Understanding what happens during a Lead merge helps administrators and developers avoid data loss and unexpected automation behavior.
Key points
When you merge Leads in Salesforce:
- Up to 3 Lead records can be merged at once (UI limit).
- You choose one record to be the master (surviving record).
- You can choose which field values to keep for each field across the merged records.
- Related records and related lists are re-parented to the master where applicable (activities, tasks, events, campaign history, etc.).
- The non-master records are deleted and placed in the Recycle Bin (can be recovered within the Org’s retention period).
- Apex triggers, workflow rules, process builders, and other automation run: losing records fire delete triggers; the master record fires update triggers.
- Merges can be performed in the UI, via the SOAP API merge() call, or in Apex using Database.merge().
Detailed behavior
Field values — During the merge UI you explicitly select which values should be retained on the master. If you use API/Apex merge, the values on the master sObject after merge are the values present on the master sObject you passed to the merge operation (or overwritten as you code it).
Related lists and child records — Most related records are reassigned to the master Lead. Examples include activities (tasks and events), open and closed, and campaign member relationships. Custom child records with lookup relationships to Lead are also reparented where possible. For child records with required relationships or sharing constraints, take care — reparenting may fail if the master violates constraints.
Attachments and Notes — Attachments, notes, files, and content associated with the losing records are typically transferred to the master record. However, always test specific related objects in your org because managed packages, custom triggers, or third-party integrations can modify default behavior.
Record deletion & Recycle Bin — The losing Lead records are deleted and moved to the Recycle Bin. They can be restored (undeleted) within the org’s retention window. Restoring a deleted lead won’t automatically “un-merge” related objects that were moved during the merge; you may need additional steps to revert relationships.
Apex & automation — Merge behaves like a combination of update (master) and delete (losers):
- Triggers: before/after delete triggers run for losing records; before/after update triggers run for the master record.
- Workflows/Process Builder/Flows can run on the master update or on delete depending on the automation configured.
- Validation rules on the master record are enforced. If the merge causes a validation error on master update, the merge will fail.
- Assignment rules, auto-response rules, and other lead-specific automation typically do not run on the deleted losing records, but may run for the master when it’s updated depending on configuration.
Programmatic merging (Apex)
Use Database.merge() in Apex to merge Leads programmatically. Example:
Lead masterLead = [SELECT Id, Company, Email FROM Lead WHERE Id = :masterId];
Lead dup = [SELECT Id FROM Lead WHERE Id = :duplicateId];
// Optionally set fields on masterLead if you want to override
masterLead.Company = 'Acme, Inc.';
Database.merge(masterLead, dup);
Database.merge can accept up to three duplicate sObjects. The call will perform the same update/delete behavior and will throw exceptions if triggers, validation rules, or other automation block the operation.
Limitations & best practices
- Converted Leads cannot be merged.
- You must have Delete permission on Leads to perform merges (and typically Edit on the master).
- Test merges in a sandbox to confirm how automation and managed packages behave in your org.
- Document merge choices and educate users: the chosen field values and which record was the master determine final data.
- Consider de-duplication tools (Duplicate Rules, Matching Rules, or AppExchange tools) to pre-filter merges and reduce manual work.
Audit and recovery
Merged (deleted) records appear in the Recycle Bin and in the standard object history/audit tools (Field History, Setup Audit Trail). If you need to examine what changed during a merge, look at field history on the master (if enabled) and the Recycle Bin contents.
Summary
Merging Leads consolidates duplicates into a chosen master record, reassigns related records, deletes the losers to the Recycle Bin, and triggers delete/update automation. Always validate automation, run tests in a sandbox, and choose field values carefully to ensure data integrity when merging leads.








Leave a Reply