Skip to main content
suresh kumar perguntou em #Apex
Hi.

I need to stop the batch or I dont want to excute the batch if my condition fails.

Simply I need to exit or break the batch.

In the below code when I tried to do nothing by returning NULL in start method i get error

System.UnexpectedException: Start did not return a valid iterable object..

global Database.QueryLocator start(Database.BatchableContext ctx){

String runBatch = false;

String sql = ' Select Id from Account where city__c ='NewYork' ;

if(runBatch == true)

return Database.getQueryLocator(sql);

}

return null;

}

I also checked the https://developer.salesforce.com/forums/ForumsMain?id=906F0000000AffaIAC

but I dont want to return itetrable object in thr try catch like this..

try{

   return iterable object;//this is correct with your existing code

}catch(Exception x){

   System.debug(Error Message);

   return iterable object;

}

I need to break or do nothing.Is ther any other ways?

cheers

suresh

 
3 respostas
0/9000