7

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.

1
  • 1
    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: salesforce.stackexchange.com/questions/7348/… Feb 18, 2013 at 17:12

2 Answers 2

2

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.

Update

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.

2
  • 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?! Feb 18, 2013 at 14:33
  • 1
    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. Feb 19, 2013 at 13:30
1
//run this command from the anonymous execution window.    
delete [select id from <Object>];

if your dealing with a custom object you can also truncate. https://help.salesforce.com/HTViewHelpDoc?id=dev_object_trunc.htm&language=en_US

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .