Uncategorized

Salesforce Batch apex Start did not return a valid iterable object

I have below batch apex code when I try to pass certain parameters through parameterized Constructor, I am getting apex batch error as “Start did not return a valid iterable object”

Here is the apex batch code.

global class DZBatchClass implements Database.Batchable {
global string query;
List ids;
String dz;

global DZBatchClass(List<Id> lstIds, String dz) {
    this.ids= lstIds;
    this.dz = dz;
}

global Iterable<Id> start(Database.BatchableContext BC){
    System.debug('###########'+ids);
    return ids;
}

global void execute(Database.BatchableContext BC, List<Id> idsToProcess) {
   // Execute logic
}

global void finish(Database.batchableContext bc){ 
    //Finish method
}
}

Got it fixed by below change in the Apex Batch Class Constructor

global BatchClass(List<Id> ids,String type) {
       this.ids= lstIds;
       this.dz = dz;
        System.debug(ds+ 'is the String and Ids are : '+ids);
    }


Leave a Reply

Your email address will not be published. Required fields are marked *