• #20367
    Salesforce | Pavan Pavan #632

    Delete more than 10000 records using script without limit in Salesforce Apex

    How to delete more than 10000 records using script without limit in Salesforce Apex?


    Salesforce | S S #628

    Better to use Data Loader for such scenario.

    Even if you have to Delete it using Apex script with some custom logic, I would recommend you to add records to collection and break it at 9990 and then create another instance of collection to update. You can write automated logic to break the collection based on the size and perform DML on them.

     Ankit Gupta #616

    Hi Pavan,

    If you are using vf page to delete the records. You can use asynchronous call to call apex method and perform the delete in each transaction.

    Also you can call action function recursively on the basis of certain condition from oncomplete of action method.

    Salesforce | Shaik Shaik #601

    Write a batch class to delete the records.

    Two ways of Executing the batch class :

    1. Execute it in “Anonymous” block or
    2. Create a VF page with a Delete button which invokes the batch class(with VF page you can catch the errors while performing delete operation and can show it on VF page as error messages)
    Salesforce | Ted Ted #644

    Hi Pavan:

    So there is no easy way to do mass deletes in Salesforce due to the limits in place. I’ve been able to use ESSA’s bulk delete feature, which is super easy.


    You can use the promotion code ESSA2017 on the register page to get the free, full version.

    I hope this helps!

    Salesforce | Parul Parul #2

    Use batch class

    Salesforce | shariq shariq #1

    Write a batch class to delete the records.



    it will work just fine. You can even write it in 1 line:

    delete [Select Id from sObject where Test__c = true Limit 9000];
    It will fail the whole delete operation though if there’s any kind of problem (like “before delete” trigger that makes some extra checks and complains). You can set it to “delete what you can, I’ll deal with errors separately” by using another version of delete that takes an extra parameter.

    Database.delete([Select Id from sObject where Test__c = true Limit 9000], false);


Viewing 8 posts - 1 through 8 (of 8 total)

Please to reply to this topic.


We're not around right now. But you can send us an email and we'll get back to you, asap.


About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2019 Forcetalks. All Right Reserved.

Log in with your credentials


Forgot your details?