You need to sign in to do that
Don't have an account?
fiona gentry
Batch showing zero records processed ,is there a way to throw exception if no Records found in Querylocator
Hi,
here is batch code which is executing currently showing as zero records processed in AysncApexJob , no errors though ,what i want is whenever batch find Zero record in SOQL of start method then batch should fail with exception or show error message
Your response is highly appreciated
Regards
Fiona
here is batch code which is executing currently showing as zero records processed in AysncApexJob , no errors though ,what i want is whenever batch find Zero record in SOQL of start method then batch should fail with exception or show error message
global class CaseCopyBatch implements Database.Batchable<sObject>, Database.Stateful { private List<Batch_Case_Type__c> processedRecords; global Database.QueryLocator start(Database.BatchableContext BC) { processedRecords = new List<Batch_Case_Type__c>(); // collect the batches of records or objects to be passed to execute String query = 'SELECT Case__c, Lvl_1__c, Lvl_2__c,Lvl_3__c,UniqueGUID__c FROM Batch_Case_Type__c WHERE createddate = today AND IsProcessed__c = false'; return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List<Batch_Case_Type__c> exeList) { // process each batch of records List<Case_Type__c> listCTD = new List<Case_Type__c>(); for(Batch_Case_Type__c exe : exeList) { listCTD.add(new Case_Type__c(Case__c=exe.Case__c,Lvl_1__c=exe.Lvl_1__c,Lvl_2__c=exe.Lvl_2__c,Lvl_3__c=exe.Lvl_3__c,ERTUniqueGUID__c=exe.UniqueGUID__c)); exe.IsProcessed__c = true; } try { insert listCTD; //only successful batches will be processed processedRecords.addAll(exeList); update processedRecords; } catch(Exception e) { System.debug(e); } } global void finish(Database.BatchableContext BC) { } }
Your response is highly appreciated
Regards
Fiona
Does https://salesforce.stackexchange.com/questions/182339/exception-thrown-by-standardsetcontroller-with-database-getquerylocator help?
Thanks