Resources /
Blog

How to Restore Deleted Leads in Salesforce

Submit your details to get a book

8
Min Read
Resources /
Blog

How to Restore Deleted Leads in Salesforce

Download

Submit your details to get a book

8
Min Read
Document with a check mark on a glowing platform, linked to clock, database, alert and copy tiles
Document with a check mark on a glowing platform, linked to clock, database, alert and copy tiles

You can restore deleted leads in Salesforce from the Recycle Bin, where they stay for 15 days by default. Pick the leads there and click Restore, or undelete them in bulk through the API if there are hundreds.

After Salesforce purges them, undelete won't work any more, and you'll need a copy you made earlier, like a Data Export file or a backup. Below we walk through each route to restore deleted leads in Salesforce, what changes for converted and merged leads, and what to check afterward.

Can you restore deleted leads in Salesforce?

Usually, yes. Deleted items remain in the Recycle Bin for 15 days by default, and users can restore them until Salesforce schedules them for permanent deletion.

Salesforce doesn't promise exactly when the bin empties them, so treat day 15 as your deadline. Deleted records there don't count against your org's storage usage.

The infographic below matches each thing that can happen to a lead with where to restore it from and what you get back. You'll find the source for each row in the sections after it.

Infographic matching five things that can happen to a Salesforce lead with where to restore it from and what comes back

Was the lead deleted, converted or merged?

Before you undelete anything, check what actually happened to the lead, because a missing lead isn't always a deleted one. Conversion, merging and deletion each leave the lead in a different state.

A converted lead is still in the org, read only but queryable, and only users with the View and Edit Converted Leads permission can update it. Fields such as ConvertedAccountId, ConvertedContactId and ConvertedOpportunityId point at the account, contact and opportunity records it became.

Merged leads are different, since a merge deletes the other records and makes the main record the new parent of their child records. Each deleted lead's MasterRecordId field holds the ID of the master record that was kept.

You can undelete a lead that a merge removed, but the merge reparents the child objects, and that can't be undone. The restored lead comes back without the child records that moved to the master record.

How do you restore deleted leads?

While the leads are still in the Recycle Bin, you can bring them back by hand or undelete them in bulk through the API. Either way you get the original records back, with their original record IDs.

From the Recycle Bin

For a handful of leads, restore them by hand. In Lightning Experience, Salesforce Help's Manage the Recycle Bin page lists these steps:

  1. Open the App Launcher, then find and select Recycle Bin, or add it to your navigation bar
  2. Choose your own Recycle Bin or the Org Recycle Bin, and use the list view to sort and filter for leads
  3. Select the records you want back and click Restore

You can bring back leads you deleted yourself with Read access on them. Bringing back leads that other users deleted, or permanently deleting records, needs the Modify All Data permission.

The Recycle Bin in Salesforce Classic sits in the sidebar on the Home page, and its View dropdown switches between My Recycle Bin and All Recycle Bin. Search by Lead Name, then select the records and click Undelete.

A lead restored from the Recycle Bin also gets back some lookups, including all custom lookup relationships, as long as they haven't been replaced in the meantime. Our guide to Salesforce Recycle Bin retention covers the bin for every object type.

In bulk with undelete

Clicking through the bin doesn't scale when an import or a bad automation removes hundreds of leads at once. The bulk route has two steps: find the lead IDs, then undelete them through the API.

Data Loader handles the first step. Its Export All option includes soft-deleted records, so a query like this one returns the missing leads and their IDs:

SOQL: Data Loader Export All
SELECT Id, FirstName, LastName, Company, Status, IsDeleted FROM Lead WHERE IsDeleted = true

Data Loader can't do the second step, though. Its import wizards cover Insert, Update, Upsert, Delete and Hard Delete, with no undelete, so you'll need one of these instead:

  • The SOAP API: queryAll() finds records deleted by a merge or delete, and undelete() brings them back by ID
  • Apex: a SOQL query with ALL ROWS returns deleted records, and the undelete statement brings them back
  • Workbench: a free web tool with an undelete operation that takes one record ID or a CSV file of IDs

Be careful with Workbench, because it "is not an official salesforce.com product" and Salesforce support doesn't cover it. Its GitHub page also says it's in maintenance only mode, with no new features and no fixes for new security issues.

Undelete also covers related data: when a parent record is deleted, its child records are cascade-deleted, and an undelete call restores those too.

Review the deleted data in the exported file before you undelete anything, since some leads may have been removed on purpose. Our Data Loader guide covers setup and the CSV workflow.

How do you recover leads after permanent deletions?

Once the default 15 days pass, the records are purged and native undelete no longer applies. A few actions get there sooner, and after an item is permanently deleted, Salesforce says you can't recover it:

  • Emptying your own Recycle Bin or the Org Recycle Bin, whose empty process you can check in View Setup Audit Trail
  • Data Loader's Hard Delete, which needs Use Bulk API or Use Bulk API 2.0 turned on in its settings, since hard-deleted records can't be recovered from the Recycle Bin
  • The API's emptyRecycleBin() call, after which records can't be undeleted

From here, the only option is rebuilding leads from a copy taken before the deletion. For most orgs, that's a Data Export file or a backup tool.

Rebuilding leads from a Data Export file

The Data Export service creates backup files of your data as a zip archive of CSV files. Three details decide how useful it is for lost leads:

  • It runs every 7 days at most on Enterprise, Performance and Unlimited editions, and every 29 days on other editions
  • The zip files are deleted 48 hours after the notification email is sent (not counting weekends), so download each one quickly
  • Formula and roll-up summary fields are always left out, so plan to recalculate them

To rebuild, take Lead.csv from the last export before the deletion and insert the missing rows with Data Loader. The inserted rows get new record IDs, because the API generates ID values automatically and won't accept the old ones.

That gap matters for related data, since activity, campaign members and other child records that pointed at the old lead IDs won't follow. Any changes made between the export date and the deletion are lost, too, and our guide on how to export data from Salesforce covers the export side.

Restoring leads from a backup

A backup tool shortens that gap to whatever changed since the last backup, which our post on RTO and RPO calls the recovery point objective. Our Salesforce backup and recovery platform guide covers what to compare between tools.

Salesforce sells its own option, Backup & Recover (formerly Own Recover). Its product page says you can "Recover the exact data you need from any backup in your history without affecting valid data added since the backup occurred."

What should you check after restoring leads?

A restore is only finished once sales and marketing can work the leads again. The checklist below lists what to confirm before you close it out.

CheckWhat to confirm
Record countA report on the restored leads matches the number you expected to bring back
OwnersEach lead's owner is still an active user, and leads in queues landed in the right one
Related recordsTasks, notes and campaign members are attached, or relinked if you rebuilt from an export
DuplicatesNobody re-created the missing leads by hand while they were gone
AutomationAssignment rules, flows and integrations that skipped these leads have been rerun
The causeYou know which user, import or job deleted the leads, so it doesn't happen again

That last row matters most. Our posts on the causes of data loss in Salesforce and on how to prevent accidental data loss cover the controls that stop a repeat.

Where Flosum fits

Backup & Archive runs as a Cloud App on Flosum-managed AWS or a VM you own, and backups are encrypted at rest and in transit.

The Backup & Archive product page describes near-continuous backups and point-in-time restore to field, record or full-org level. That's "not just an all-or-nothing recycle bin," and it's backed by Flosum's $100,000 restore guarantee.

With deleted data in a backup, you aren't racing the Recycle Bin or living with the gap since the last weekly export. Our guide to automated Salesforce backup and restore shows how scheduled backups fit a wider data protection plan.

FAQs

How long do deleted leads stay in the Salesforce Recycle Bin?

Fifteen days by default. After that, Salesforce schedules them for permanent deletion at a time it doesn't guarantee, so act well before the window closes.

Can Data Loader undelete leads?

No, but Data Loader can export soft-deleted leads with Export All, which gives you their IDs. To undelete them, use the API's undelete() call, Apex or another tool that supports it.

Who can restore leads that another user deleted?

In Lightning Experience or Salesforce Classic, a user with the Modify All Data permission. Without it, you can only view and restore the records you deleted yourself.

Do restored leads keep their original record IDs?

Yes, when you restore them from the Recycle Bin or with undelete, because the same record comes back. Leads rebuilt from an export get new IDs, since create() calls can't set an ID value.

How do I find out if a missing lead was converted?

Query the lead and check its IsConverted field. Conversion doesn't delete a lead, since Salesforce keeps it as a read-only record whose ConvertedContactId and ConvertedAccountId fields lead you to the new account and contact records.

Book a demo to see how Flosum Backup & Archive restores deleted Salesforce leads from a point-in-time backup.

Table Of Contents
Author
Stay Up-to-Date
Get flosum.com news in your inbox.

Thank you for subscribing

Ship Salesforce changes faster
Teams on Flosum report 40% higher development velocity and 75%
fewer merge conflicts.
Free to start  |  No credit card required