You need to sign in to do that
Don't have an account?

Batch apex for list of ids : First error: Start did not return a valid iterable object.
Hi,
I have list of ids and these Ids should be processed using batch apex.
I'm getting below error while executing batch apex.
First error: Start did not return a valid iterable object.
**Any help is really appriciated. Thanks in advacne.
Thanks,
Naveen.
I have list of ids and these Ids should be processed using batch apex.
I'm getting below error while executing batch apex.
First error: Start did not return a valid iterable object.
global class BatchClass implements Database.Batchable<Id> { global string query; List<Id> ids; String type; global BatchClass(List<Id> ids,String type) { ids= new List<Id>(); ids=this.ids; type=this.type; System.debug('########## constructor'+ids); } global Iterable<Id> start(Database.BatchableContext BC){ System.debug('###########'+ids); return ids; } global void execute(Database.BatchableContext BC, List<Id> idsToProcess) { //Processing // } global void finish(Database.batchableContext bc){ } }
BatchClass b= new BatchClass(Ids,'Process');//Ids : List of Ids Database.executeBatch(b);
**Any help is really appriciated. Thanks in advacne.
Thanks,
Naveen.
Please change you Constructor as below, here left hand side is having this.Ids rather then right hand side like you used.
It will work fine.
Thanks
Shashikant
All Answers
Please change you Constructor as below, here left hand side is having this.Ids rather then right hand side like you used.
It will work fine.
Thanks
Shashikant
Thanks for your valuable response. Now that exception is avoided. But below is the output I'm getting.
output is:
Can you advice me how to pass these Ids to execute() method.
Thanks,
Naveen.
ids= new List<Id>();
See the constructor that I mentioned in my first resposne. It did not had that.
Were you able to resolve the issue with above change ?
Thanks
Shashikant
Had some other issue but able to resolve that. Made below changes.
You answer also helped me in resolving above exception I'm marking it as best answer.
Thanks,
Naveen.
Good that my answer helped, I think you marked the other post which swas during discussion was going on. I think main issue was in was wrong placing of this in the constructor as without maing it global batch was running. Just make sure mark the appropriate post so that others could be benifitted from this discussion.
Thanks
Shashikant