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?
What permission is required?
How to enable this option?
How to truncate the custom object?
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.