Have you ever dealt with the requirement where you need to delete all records from a custom object? There are multiple ways to do that like – running anonymous scripts, running batch classes, deleting from Workbench, etc. But as you can understand all of these solutions either need some sort of custom coding to make sure you are not hit by the Governor limits of the platform.

In this post, I am going to share the quickest and easiest solution to truncate any custom objects.

Is it available in Classic and Lightning both?

No, unfortunately, this option is only available in classic.

What permission is required?

You need “Customize Application” permission.

How to enable this option?

You need to first go to the Classic version of Salesforce. Then search for “User Interface” in the Quick Find search window. Then check the option “Enable Custom Object Truncate“.

How to truncate the custom object?

With the Custom Object Truncate option enabled, if you go to custom object definition, you will find the truncate button at the top. Clicking on that will ask you to enter the object name and then Salesforce will truncate the entire object. Isn’t it quick? No custom coding required and no need to worry about Salesforce’s Governor Limit.

Anything you need to keep in mind?

  • The truncate operation will fail if –
    • There is any reference to other objects through lookup or master-detail relationships.
    • The object is referenced in reporting snapshots.
    • The object is having a custom index or an external ID.
    • Have activated skinny tabled.
  • Truncate is going to delete the records permanently. So you will not be able to recover records from Recycle Bin.
  • A copy of the truncated object will be kept in the Deleted Objects list for 15-days.

Video with my experiments in truncating custom objects