Salesforce — quickly delete all custom object records

Cloud Architect
2 min readJan 3, 2024

I recently had a scenario where I was developing a custom object, filling it with millions of records and then deleting them again. The usual advice is to export all the id’s to a csv file with Salesforce DataLoader, and then use DataLoader to delete those same records with the csv as the input.

This works but take hours to delete millions of records.

Salesforce actually has a truncate function — in database terms this just means empty a table of all records. This currently appears only available in Classic Mode:

  1. Switch to Classic Mode
  2. Go to Setup
  3. Navigate to Build->Customize->User Interface
  4. On this screen, find the ‘Enable Custom Object Truncate’ checkbox. Enable it. Save it.
  5. Go to the details page of your custom object. A ‘truncate’ button will appear. Click it.

Note: This functionality behaves like a deletion but does not actually reduce your storage use. It gets renamed with an “_trunc” appended and will take 15 days to actually delete and be removed from your storage limit. I don’t think there is any way to accelerate this, even with the recycle bin.

Disclaimer: This is an awesome feature for developing (although a true immediate truncate would have been much better). I’d suggest never touching this in Production. It is very unlikely that you could get your data back if a mistake was made.

--

--