Is it possible to trigger a truncate of an object in Salesforce? As a job etc.? Deleting the data from an object needs the Ids to be cached/stored and then deleted from the Salesforce. Even using "BulkAPI" is proving to be too slow for us. I have heard that we can Truncate an object in Saleforce which is quite fast. How do we do that?
Currently there is no way to
truncate the object using
API. There is an idea posted which you can up-vote so that Salesforce takes this up to deliver this in future releases.
One other way of doing this would be to do this using
batch class which won't require you to hold the
IDs and will asynchronously delete the records from the object. You can go through Asynchronous Apex trailhead module to get some further help on batch classes.
Note : The
auto number fields won't get reset after deleting the records using batch apex i.e. using delete statements which does reset when truncating the object.