Truncate Custom Objects in Salesforce

by Sudipta Deb | Nov 16, 2020 | admin, Advanced Admin, Custom Object, Delete, Recycle Bin, Truncate | 0 comments

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

Written by

Related Posts

How To Delete Lightning Web Component From Org

How To Delete Lightning Web Component From Org

With the introduction of Lightning Web Component, developers can now build lots of cool UI (User Interface) components. In order to develop Lightning Web Component (LWC), developers need an editor (preferably Visual Studio Code) and then deploy the component through package or through changeset. But unlike other metadata available in Salesforce, deleting Lightning Web Component is not that straightforward. You can’t delete a Lightning Web Component from Salesforce Setup. In this blog post, I am going to share couple of ways you can delete the bundle from Salesforce Org.

read more...

0 Comments

Leave a Reply