Activity Forums Salesforce® Discussions How can we Delete mass Accounts from org using Dml operation in salesforce?

  • How can we Delete mass Accounts from org using Dml operation in salesforce?

  • Vikas Kumar

    Member
    January 4, 2017 at 12:35 pm

    Hi All,

    Is there a DML or other way to delete all records from the developer console?

    thanks

  • Kumar

    Member
    January 6, 2017 at 1:34 pm

    Hi vikas,

    There is no soql command to delete rows directly. What you can do instead is to create a list with all the accounts in your org and then delete that list.

    For example:

    list<Account> acc = [SELECT id FROM Account];                                                                                                 delete acc;

    Hope this helps.

  • shariq

    Member
    August 4, 2017 at 10:16 am

    Hi Vikas,

    You may use Batch Class to delete all records of Account sobject.

    For Example :-

    Global class BatchMassDeleteRecs Implements Database.batchable<sobject>{
    global final string query;
    global BatchMassDeleteRecs(string q){

    query=q;
    }

    global Database.QueryLocator start(Database.BatchableContext BC){

    return Database.getQueryLocator(query);
    }
    global void execute(Database.BatchableContext BC,List<SObject> scope){
    delete scope;

    }
    global void finish(Database.BatchableContext BC){
    }

    }

Viewing 1 - 3 of 3 posts

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos