There are situations that you have to quickly delete all records from one object, for example you have created a custom object and filled it with test records. Once you are done with the test data you would like to truncate the object to purge the test records but to keep all object’s metadata (fields, validation rules etc). Of course there are ways like Data Loader or writing some small Apex code to achieve that task but mass delete records in Salesforce should be an easy job.

Standard Objects

Here situation is pretty straightforward. Salesforce offers standard mechanism to delete standard objects (Lead, Account, Contact, Case) records. You simply have to navigate to the object’s tab, let’s say Leads in our case:

Once you are there just click on Mass Delete Leads in Tools section:

In a new screen you can provide filter criteria for Leads that you want to delete. If you just click Search then all records will be presented. Now you just select all of them and click Delete. Prior to that you can check Permanently delete option that omits Recycle Bin during deletion process and removes records forever.
Alternative way to delete standard records is to select Setup | Data Management | Mass Delete Records:

Custom Objects

For custom object, Salesforce has specially dedicated function called Truncate. It will permanently remove ALL records, but object and its metadata remain intact for future use.

First of all, you have to activate that option in Salesforce’s Setup. Go to Setup | Customize | User Interface and check Enable Custom Object Truncate in Setup section:

Now, if you navigate to any custom object, you can see the difference – new button called Truncate has appeared.

Let’s click Truncate. Once you confirm deletion Salesforce will create a new object end with _trunc (in my case Order_trunc). This object appears in the Deleted Objects list for 15 days.

It contains all fields and records deleted from the original object, so you can consider it like a temporary backup.

Keep in Mind


  • To truncate objects that contain master-detail relationships, first truncate the detail (child) objects and then the (master) parent objects, working your way up the relationship tree.
  • The truncated object tab has a new URL, so new bookmarks need to be created

Truncating a custom object erases:

  • All records currently sitting in the custom object’s Recycle Bin
  • The custom object’s history
  • Related events, tasks, notes, and attachments for each deleted record
You can’t truncate standard objects or custom objects that:

  • Are referenced by another object through a lookup field or that are on the master side of a master-detail relationship
  • Are referenced in a reporting snapshot
  • Have a custom index or an external ID
  • Have activated skinny tables

In addition, you can’t truncate custom objects when your org has reached its limit on allowed custom objects.


Read more on Salesforce help.

(Visited 833 times, 1 visits today)