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 apex or 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.

| improve this answer | |
  • Thanks Vijay. We definitely need this feature through API. Upvoted the idea. – user70782 Jul 16 '19 at 8:33
  • @user70782 Hope this gets delivered in future releases. – Vijay Ganji Jul 17 '19 at 6:27
  • Hi @user70782 if this or any answer has solved your question please consider accepting it by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both the answerer and yourself. There is no obligation to do this. – Vijay Ganji Jul 23 '19 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.