0 votes
1 view
in Salesforce by (11.9k points)

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?

1 Answer

0 votes
by (31.6k points)

Your class declaration should be:

global class CleanUpRecords implements Database.Batchable<sObject> {

instead of:

global class CleanUpRecords implements Database.Batchable<Object> {

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...