Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a development org with a quite complex object structure and a ton of demo data. To refactor thr structure I want to get rid of all this data.

My first thought was to use the new "Truncate" button on objects, but that would mean I would have to delete child records first. For a structure like this this is not something you just calculate in 5min.

Is there another way to do this? I also tried the "Delete All Data" but that gave up as my org has too much data.

share|improve this question
Truncate button does not show up in 4 cases: (1) Are referenced by another object through a lookup field or that are on the master side of a master-detail relationship (2) Are referenced in an analytic snapshot (3) Contain a geolocation custom field (4) Have a custom index or an external ID. See this:… – Suman Krishna Saha Feb 18 '13 at 17:12

Since you are talking about a Development Org, I would first recommend just creating a new one since they are free; otherwise I would script out the truncate calls, object by object. This would simplify your task and provide automation for the future.


I'm not sure if you can programmatically determine your dependencies, so I would handle that by visual inspection of the schema. As for examples on how to handle the bulk deletes, I would expect using the Data Loader to be the quickest method since it already handles the batching for you and can be called from the command line. You can refer to the Data Loader Guide for examples.

share|improve this answer
I can't just create a new org but I like the script option. Is there any example around on how to do this. I guess I would need Batch Apex for the deletion and some kind of dependency sort for the deletion order?! – Robert Sösemann Feb 18 '13 at 14:33
I found out that you indeed can determine this with code by doing a topographic sort on the dependency graph. I am currently trying to put that into a helper class. – Robert Sösemann Feb 19 '13 at 13:30
//run this command from the anonymous execution window.    
delete [select id from <Object>];

if your dealing with a custom object you can also truncate.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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