I am currently using the Apex Workbook to refresh my knowledge of SalesForce.
Tutorial #15, Lesson 1: Offers the following code:
global class CleanUpRecords implements Database.Batchable<Object>
{
global final String query;
global CleanUpRecords (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;
Database.emptyRecycleBin(scope);
}
global void finish(Database.BatchableContext BC)
{
AsyncApexJob a = [
SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email
FROM AsyncApexJob
WHERE Id = :BC.getJobId()
];
// Send an email to the Apex job's submitter
// notifying of job completion.
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {a.CreatedBy.Email};
mail.setToAddresses(toAddresses);
mail.setSubject('Record Clean Up Completed ' + a.Status);
mail.setPlainTextBody (
'The batch Apex job processed ' + a.TotalJobItems +
' batches with '+ a.NumberOfErrors + ' failures.'
);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
However, regardless of which development interface (e.g. Force IDE, console, setup) I use, when I try to save this, I get:
Multiple markers at this line
- File only saved locally, not to server
- Save error: CleanUpRecords: Class must implement the global interface method: Iterable<Object> start(Database.BatchableContext) from Database.Batchable<Object>, CleanUpRecords: Class must implement the global interface method: void execute(Database.BatchableContext, LIST<Object>) from
Database.Batchable<Object>
(Or some equivalent, depending upon how I try to save it.)
However, it seems to me the required methods are already there.
What's missing?
Prepare to be frustrated ... there's just one character off.
Your class declaration should be:
global class CleanUpRecords implements Database.Batchable<sObject> {
instead of:
global class CleanUpRecords implements Database.Batchable<Object> {
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With