function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Das MDas M 

Compile Error: Class must implement the global interface method: Iterable

Hi, I am getting followinng error whilt I try to save this Class. Could someone help to fix this ?

Error: Compile Error: deleteInventory: Class must implement the global interface method: Iterable<Inventory__c> start(Database.BatchableContext) from Database.Batchable<Inventory__c> at line 1 column 14
global class deleteInventory implements Database.Batchable<Inventory__c>{
    global final String Query;
    global deleteInventory(String q){
        Query=q;
    }

    global Database.QueryLocator start(Database.BatchableContext BC){
        return Database.getQueryLocator(query);
        
            
    }

    global void execute(Database.BatchableContext BC,List<Inventory__c> scope){
        delete scope;
    }

    global void finish(Database.BatchableContext BC){
    // Get the ID of the AsyncApexJob representing this batch job
    }

}

 
pconpcon
What version of the API is this class?  You can just change line 7 to read what is below and use the Iterator [1] instead.
 
global Iterable start(Database.BatchableContext BC) {

[1] https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm#apex_batch_iterable
Pulkit SoodPulkit Sood
change to global class MyBatchableclass implements Database.Batchable<SObject>{}