0

I am trying to update a batch class to allow me to schedule it, but I am getting this error:

Class must implement the following methods System.ScheduleableContext

I understand the error, but given my code works when I manually execute the job I am not aware how to update it to still work and also be schedulable.

public class DataRefreshBatch implements Schedulable, Database.Batchable<SObject>,  Database.Stateful,  Database.AllowsCallouts{

    public List<Jobs__c> start(Database.BatchableContext bc) {
     /*....*/
    }

   public void execute(Database.BatchableContext bc, List<Jobs__c> scope) {
     /*....*/
   }

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

The error is in the first line, when I added "Scheduleable" after implements, I get an error in my IDE showing the error message above. My start method returns a list of records from a custom object that I then use in my execute method.

What modification is needed to allow me to make this class scheduleable and still keep the method signature the way it is on my execute method.

1 Answer 1

1

You need to include an execute(SchedulableContext) method. Typically:

public void execute(SchedulableContext context)
{
    Database.executeBatch(this);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.