🗑️ Mass Delete: Safe Bulk Deletion Guide
⚠️ Critical: Mass Delete permanently removes records. Always test in sandbox, backup data, and use preview mode before executing deletions.
Mass Delete safely removes thousands of unwanted records with advanced query filtering, preview confirmation, audit trail, and recovery options. Clean test data, remove duplicates, and manage data lifecycle with confidence.
🎯 Core Safety Features
👁️ Preview Mode
- Review Before Delete: See exact records
- Record Count: Confirm quantity matches expectation
- Sample Display: View first 100 records
- Export List: Download CSV of records to delete
- Cancel Anytime: No changes until confirmation
📋 Audit Trail
- Deletion Log: Who, what, when for every delete
- Record IDs: Archived for recovery
- Field Values: Snapshot before deletion
- Query History: SOQL used for selection
- Compliance Reports: Export audit logs
♻️ Recovery Options
- Recycle Bin: Soft delete (15-day retention)
- Bulk Restore: Undelete multiple records
- Permanent Delete: Hard delete with confirmation
- Export Before Delete: Backup to CSV
- Related Records: Handle child records
🔒 Safety Controls
- Query Validation: Verify SOQL syntax
- Max Record Limit: Batch size caps
- Confirmation Prompts: Multi-step approval
- Role-Based Access: Restrict delete permissions
- Sandbox-Only Mode: Prevent production deletions
📋 Common Deletion Scenarios
Scenario 1: Remove Test Data
Goal: Delete all test Leads created during training
- Object: Lead
- Query:
LastName LIKE 'TEST%' - Preview: 1,234 records found
- Export backup CSV
- Execute soft delete (Recycle Bin)
- Result: Test leads removed, recoverable for 15 days
Scenario 2: Clean Old Opportunities
Goal: Remove closed-lost Opportunities older than 2 years
- Object: Opportunity
- Query:
StageName = 'Closed Lost' AND CloseDate < LAST_N_YEARS:2 - Preview: 5,678 records
- Verify no related quotes/contracts
- Export audit backup
- Execute soft delete
Scenario 3: Remove Duplicate Contacts
Goal: Delete duplicate Contacts after merge
- Use DEDUP-Manager to merge duplicates first
- Query:
Email IN ('dup1@example.com', 'dup2@example.com') - Preview: Verify only duplicates selected (not masters)
- Execute soft delete
- Monitor related records: Tasks, Opportunities preserved on master
Scenario 4: Bulk Delete by CSV
Goal: Delete specific records from uploaded CSV list
- Prepare CSV with Record IDs column
- Upload CSV file
- Preview: 342 records matched
- Verify IDs are correct
- Execute deletion
⚙️ Step-by-Step: Safe Deletion Process
Step 1: Select Records
- Open Mass Delete from App Launcher
- Select object: Lead
- Choose selection method:
- SOQL Query: Custom filter criteria
- List View: Use existing view
- CSV Upload: Specific Record IDs
- Enter query:
Status = 'Unqualified' AND CreatedDate < LAST_YEAR
Step 2: Preview & Validate
| Validation Check | Expected Result | Action |
|---|---|---|
| Record Count | 3,456 records | ✅ Matches expectation |
| Sample Review | All Unqualified + old dates | ✅ Criteria correct |
| Related Records | 0 related Tasks/Events | ✅ Safe to delete |
Step 3: Backup & Export
- Click “Export to CSV”
- Download includes:
- All field values
- Record IDs
- Created/Modified dates
- Owner information
- Save backup to secure location
- Document reason for deletion
Step 4: Execute Deletion
- Choose deletion type:
- Soft Delete (Recycle Bin): Recommended – 15-day recovery
- Hard Delete (Permanent): Requires additional confirmation
- Enter confirmation code displayed on screen
- Click “Delete Records”
- Monitor progress: “Deleting 3,456 records… 87% complete”
- Review completion report:
- ✅ Successfully deleted: 3,450
- ⚠️ Failed (locked records): 6
🔄 Handling Related Records
Cascade Deletion Rules
| Parent Object | Child Records | Behavior |
|---|---|---|
| Account | Contacts, Opportunities | ⚠️ Blocked – must delete children first |
| Contact | Tasks, Events | ✅ Auto-deleted (cascade) |
| Lead | Tasks, Events | ✅ Auto-deleted (cascade) |
| Opportunity | Opportunity Line Items | ✅ Auto-deleted (cascade) |
| Custom Object | Master-Detail children | ✅ Auto-deleted (cascade) |
✅ Safety Checklist
Before Deletion
- ☑️ Test query in sandbox with sample data first
- ☑️ Export backup CSV of records to be deleted
- ☑️ Verify record count matches expectation
- ☑️ Review sample records – check first 20-50
- ☑️ Check related records – will child records be deleted?
- ☑️ Notify stakeholders – get approval for large deletions
- ☑️ Schedule deletion during off-peak hours
- ☑️ Use soft delete (Recycle Bin) unless absolutely necessary
🚫 Never Delete Without
- ❌ Backup: Always export before deleting
- ❌ Preview: Review records in preview mode
- ❌ Approval: Get manager approval for >1,000 records
- ❌ Testing: Test query in sandbox first
🔍 Query Examples
Delete by Date Range
Lead WHERE CreatedDate < 2024-01-01 AND Status = 'Unqualified'
Delete by Custom Field
Contact WHERE Data_Quality_Score__c < 30 AND Email = null
Delete Test Records
Account WHERE Name LIKE 'Test%' OR Name LIKE '%Demo%'
Delete by Owner
Lead WHERE Owner.Name = 'Integration User' AND CreatedDate = LAST_N_DAYS:90
⚡ Performance Guidelines
| Record Count | Deletion Time | API Method | Recommendation |
|---|---|---|---|
| 1 – 500 | 30 seconds – 2 minutes | REST API | Execute immediately |
| 500 – 5,000 | 2 – 10 minutes | REST API (batched) | Monitor progress |
| 5,000 – 50,000 | 10 – 45 minutes | Bulk API | Schedule off-peak |
| 50,000+ | 1 – 3 hours | Bulk API (parallel) | Split into batches |
♻️ Recovery Procedures
Restore from Recycle Bin
- Navigate to Recycle Bin in Salesforce
- Filter by object type and date deleted
- Select records to restore (max 200 at a time via UI)
- Or use Mass Delete → Restore tab:
- Query deleted records:
isDeleted = true AND DeletedDate = TODAY - Preview restore candidates
- Click “Restore Selected”
- Monitor restore progress
- Query deleted records:
💡 Recovery Time Limits
- Recycle Bin Retention: 15 days (standard), 30 days (enterprise with license)
- Hard Deleted Records: Cannot be recovered via UI
- Contact Salesforce Support: Recovery may be possible within 30 days for hard deletes (not guaranteed)
- CSV Backups: Keep export files for at least 90 days
🔧 Troubleshooting
Problem: “Cannot delete record” errors
Common Causes:
- Record is locked by approval process
- Related child records exist (Accounts with Contacts)
- User lacks delete permission
- Validation rules prevent deletion
- Record in use by workflow/process
Solutions:
- Recall approval or wait for completion
- Delete child records first
- Verify permissions with System Administrator
- Temporarily disable validation rules (with approval)
Problem: Deletion taking too long
Performance Tips:
- Split into smaller batches (10,000 records max per batch)
- Delete during off-peak hours (evenings, weekends)
- Remove complex triggers temporarily (with approval)
- Use Bulk API for large deletions (auto-selected for 5,000+ records)
- Schedule sequential batches with 10-minute gaps
Problem: Accidentally deleted wrong records
Immediate Actions:
- Stop deletion job if still in progress
- Go to Recycle Bin immediately
- Filter by DeletedDate = TODAY
- Select all deleted records
- Click “Undelete”
- If hard deleted: Contact Salesforce Support within 24 hours
Prevention:
- Always preview before executing
- Test queries in sandbox
- Start with small batches (100 records)
- Use soft delete (Recycle Bin) by default
✅ Best Practices
Deletion Workflow
- Plan: Document deletion criteria and approval
- Test: Verify query in sandbox with sample data
- Backup: Export CSV of records before deletion
- Preview: Review records in preview mode
- Start Small: Delete 100-500 records as pilot
- Monitor: Watch for errors during deletion
- Verify: Confirm expected records deleted
- Document: Log deletion in audit system
Enterprise Governance
- ☑️ Require manager approval for >1,000 records
- ☑️ Executive approval for >10,000 records
- ☑️ Schedule large deletions during maintenance windows
- ☑️ Notify users before deleting shared records
- ☑️ Keep audit logs for 1 year minimum
- ☑️ Review deletion patterns quarterly
📊 Deletion Audit Report
Every deletion generates comprehensive audit report:
| Audit Field | Captured Data |
|---|---|
| Deleted By | User name and ID |
| Deletion Time | Timestamp (UTC) |
| Object Type | Lead, Contact, Account, etc. |
| Query Used | Full SOQL query |
| Records Targeted | Count from preview |
| Successfully Deleted | Count of completed deletions |
| Failed Deletions | Count + error reasons |
| Deletion Type | Soft (Recycle Bin) or Hard (Permanent) |
📚 Related Documentation
Last updated: March 2026 | Back to Documentation | Home