function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JoannaJoanna 

How Can I Delete All Data in a Custom Object?

I have a custom object "Projects", which I imported data into.  The requirements have changed regarding the unique identifier data, so I need to delete the imported records and import new records.  How can I delete all of the data in the custom object?  I don't want to delete the entire "Projects" object because I have defined a lot of custom fields and do not want to lose that work.  I just want to delete all the records in that object.

Thanks so much!
RickyGRickyG
Joanna -

When I have faced the same task, I simply used Data Loader to do an export of the IDs from the object, and then used that file with Data Loader to delete the rows.  Others may have better ideas, but this was easy and fairly fast for my 2K of records.

Hope this helps.

DevAngelDevAngel
Rick has the right pattern, whether you use dataloader or your own mini app, you need to fetch all the ids for the object you want to purge, then, in batches, run the delete call passing in ids.

Cheers
JoannaJoanna
Thanks.  That was very helpful.