Skip to main content
i need hard delete all account records  with out cheaking  recyclebin will select all and delete it

how it wii possoble which method will uses

 
1 个回答
  1. 2016年4月27日 08:24
    Anyhow you need to call  database.emptyrecyclebin() to delete your data permanently through Apex.

    You can take help of below Batch Class  to delete your all account:

     

    global class BatchDeletion implements Database.Batchable<sObject>, Schedulable

    {

    global void execute(SchedulableContext sc)

    {

    BatchDeletion deleteCS = new BatchDeletion();

    ID batchprocessid = Database.executeBatch(deleteCS, 200);

    }

    global Database.QueryLocator start(Database.BatchableContext bc)

    {

    return Database.getQueryLocator([Select id from Account]);

    }

    global void execute(Database.BatchableContext BC, list<sObject> scope){

    delete scope;

    DataBase.emptyRecycleBin(scope);

    }

    global void finish(Database.BatchableContext BC){}

    }