1

Given the following code:

global class MyBatch implements Database.Batchable<SObject> {

    global MyBatch() {}

    global void execute(Database.BatchableContext BC, List<MyBatch Field__c> batch)
    {

    }

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

What does this error Message mean?

MyBatch: Class must implement the global interface method: Iterable<SObject> start(Database.BatchableContext) from Database.Batchable<SObject>

1 Answer 1

3

It means that you're missing a particular method; the interface is trying to enforce the implementation of this class.

So adding this method to the MyBatch class will resolve the issue:

    global Database.Querylocator start (Database.BatchableContext BC)
{
       return Database.getQueryLocator(query);
}   
4
  • 2
    n.b. Unless you are doing managed packages, you can use public rather than global as access modifier throughout your batch class
    – cropredy
    Commented May 20, 2015 at 22:25
  • @crop1645 That's good to know. Thank you!
    – chrisjlee
    Commented May 21, 2015 at 2:49
  • 1
    yep - I learned it from @sfdcfox who knows everything
    – cropredy
    Commented May 22, 2015 at 9:17
  • You can write a batch in a managed package that uses public rather than global too. Global is only needed to expose the class or method to code outside the package.
    – Phil W
    Commented Mar 8, 2019 at 0:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .