I added a custom object and some fields. I also added several entries to the database for this object. Can I delete certain entries or all of them at once that relate to my object in some predefined way, or do I need to write my own code for this?

  • You can import the data and then mark the field value as null and update them again using data loader Commented Jun 7, 2021 at 13:53
  • You can go into more detail. I'm a newbie and I don't understand what exactly it is about? Commented Jun 7, 2021 at 14:03
  • check out this module on trailhead trailhead.salesforce.com/content/learn/modules/… In your case you can Export data first then update the data instead of Import. Commented Jun 7, 2021 at 14:05
  • If you want to delete all records, you could check the truncate option Commented Jun 7, 2021 at 14:10

3 Answers 3


To clear out the every record in the Custom Sobject

delete [select Id From Custom_Sobject__c];

> Can I delete certain entries or all of them at once that relate to my object in some predefined way

If your custom object has a master-detail field (is the detail/child in this relationship), when the parent is deleted, the child will be deleted automatically. It's called cascade delete.

Apparently, cascade delete could be enabled in lookup too but I haven't used it yet. https://help.salesforce.com/articleView?id=000313755&type=1&mode=1

if none of the above suits you

You will need to write a trigger to handle the cascade delete.


We can do this by two way:

  1. Use data loader/workbench to export the ids of the records and use the delete operation of DL/workbench to delete them.

  2. Create a batch apex, which queries all records in the start method. In executing method add them to list and delete the records. Run the batch suing dev console. This ensures that you don't run into any governor limits.


I solved this issue like this: I went to the developer console in the upper-right corner of the web browser. I clicked Debug > Run Anonymous Apex:

List<Exchange_Rate__c> listDelete = [select Id From Exchange_Rate__c];
delete listDelete;

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