You need to sign in to do that
Don't have an account?
Churchill19
Help with testing my BulkRecordDelete Batch code
Hi all,
can anyone help with a example of test code so i can test the following batch code please?
can anyone help with a example of test code so i can test the following batch code please?
global class BulkRecordDelete implements Database.Batchable<sObject> { global string obj; private string query = 'SELECT Id FROM '; global database.querylocator start(Database.BatchableContext BC) { query = query + obj; return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List<sObject> scope) { List<sObject> ob = new List<sObject>(); for(sObject s : scope) { ob.add(s); } delete ob; } global void finish(Database.BatchableContext BC) { if (ApplicationClass.BatchEmailsEnabled) { Id userId = UserInfo.getUserId(); String notify = [select Email from User where Id = :userId].Email; Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setToAddresses(new String[] {notify}); mail.setReplyTo('batch@acme.com'); mail.setSenderDisplayName('Batch Processing'); mail.setSubject('Batch Process Completed'); mail.setPlainTextBody('Bulk ' + obj + ' delete has completed'); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); } } }Thanks...
http://www.salesforce.com/us/developer/docs/apex_workbook/Content/apex_batch_2.htm
thanks for this it worked :)
Sean.