TransWikia.com

Developer Console - Delete Multiple Records

Salesforce Asked by Uri Lukach on November 28, 2021

Is there a DML or other way to delete all records from the developer console? For example, we have 100K Leads in our testing environment and we would like to delete all of them in one operation.

Is that possible?

By the way, I saw there is a mass delete option, although it only lets you delete a few hundreds records at a time…. (using Setup-> Administration Setup->Data Management -> Mass Delete Records.)

7 Answers

I have made an open source GitHub project for deleting multiple records in batches. you can go through the project and embrace the functionalities as per your requirements. Github Repo : https://github.com/vipul-goyal/Salesforce-Batch-To-Delete-Records

Answered by Vipul Goyal on November 28, 2021

To delete more than 50,000 records, you can use the DataLoader program. Follow these steps...

-Open the data loader and choose "export". Navigate to your object and select it, then choose the 'id' field. You only need the 'id' for each record in order to delete it. Export this to a csv file.

-Open the data loader again and choose "delete". Navigate to your object and select it. Then import the csv file you have just saved containing the IDs for all your records. Import that and map the 'id' field to that of your object.

Answered by Erich Purpur on November 28, 2021

2 ways,

  • Either batch apex with acceptable batch size and business logic.
  • Apex Data Loader (as explained in above answers)
    • Using bulk api you can really speed up the deletion.
    • Normal apex loader deletion can also do the trick with specified batch size.

Answered by Pradeepkumar'2552866 on November 28, 2021

One way to delete using Developer Console is to first execute your query

SELECT Id from My_Custom_Object__c

Then highlight all the result rows and click on the Delete Row button at the bottom.

enter image description here

Answered by Bhavana on November 28, 2021

I add something to your answers. There are two ways to solve this problem, in addition to the console. I think that the console could be very useful, but maybe in production one wants to have an higher "control" on the data. In that case there are two ways.

1) Use the Workbench:

  • connect to the product (if you have a developer licence check this option) or to the test org;
  • Tab Query - click on SOQL query;
  • write a query to identify the records to delete: SELECT Id FROM Account WHERE revenue > 1234 ;
  • check the Bulk CSV radio button;
  • click on the "Query" button, wait the processing of the records, and then download it (it will be saved in .csv format);

This file can now be used to delete those records from the org:

  • Tab Data - click on Delete;
  • Eventually enter again in your org;
  • choose the From File radio button;
  • Map the field;
  • Delete all!

1) Use the Data Loader:

  • download it from

Setup - Data Management - Data Loader

  • enter in the Data Loader using the password of your org + the security token;
  • check in the Settings tab if you are accessing in the right environment (test.salesforce or login.salesforce);
  • following the instructions suggested in the previous answer.

Answered by Andrea Ianni ௫ on November 28, 2021

Using Apex Data Loader to delete records:

First, you have to export all the records (the ID will be sufficient) to a csv file. Then you can delete all the records based on that csv file. When you perform the delete make sure you map the ID column of the csv file to the Id column of the object.

This way took me a few minutes to delete 120K records (Lead).

Answered by Uri Lukach on November 28, 2021

You can delete records from the developer console with the line

delete [SELECT Id FROM MyObject];

However, this isn't going to delete 100k records successfully due to governor limits. You're going to need to use dataloader to export the 100k records, then use the export to delete the records.

Edit: Better than that, you can use LIMIT to select a subset, and then rerun the command after each execution

delete [SELECT Id FROM MyObject LIMIT 10000];

Answered by Phil Rymek on November 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP