• #20367
    Salesforce | Pavan Pavan #632
    Forcetalks

    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?

     

    #20370
    Salesforce | S S #628
    Forcetalks

    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.

    #20373
     Ankit Gupta #616
    Forcetalks

    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.

    #20414
    Salesforce | Shaik Shaik #601
    Forcetalks

    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)
    #20976
    Salesforce | Ted Ted #644
    Forcetalks

    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.

    https://www.essa-software.com/

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

    I hope this helps!

    #39925
    Salesforce | Parul Parul #2
    Forcetalks

    Use batch class

    #40913
    Salesforce | shariq shariq #1
    Forcetalks

    Write a batch class to delete the records.

    #41340
    Forcetalks

    Hello,

    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);

    Thanks.

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

Please to reply to this topic.

CONTACT US

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

Sending

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

or    

Forgot your details?