You need to sign in to do that
Don't have an account?
suresh.csk
Break or Stop Batch in start method.Do nothing in start method and exit from batch
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
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
Reference :
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_system.htm#apex_System_System_abortJob
Thanks for the reply.Yes Yes we can use abortjob.
Other than this any idea ?
ex: