function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jos VervoornJos Vervoorn 

Batch class exception error

Hi,

We have a batch class running but it's failing because of the records it needs to process. We are running into SOQL query governor limits. So, for the time being, we limited the record selection and changed the frequency. For the short term just fine however while developing a new and improved class, I was wondering if it would be possible to commit all processed records before an exception. This way the records to be processed would not pileup and making sure that only the failing row remains unprocessed.

Like for example if the batch would close all cases which have been waiting for customer feedback for 28 days (or more)  all would be processed except the few cases which have caused an exception.
VamsiVamsi
Hi Jos,

You can make use of Database methods to get this done instead of just Insert or update commands.

Ex : List<Database.saveResult> FinalInsertList = Database.Insert(AccountList,flase); // AccountList specifies the list of record that needs to be processed and false indicates perform partial insert of records -> mean even though if there is an error during the transaction it will continue to executing by keeping the error records aside.

Please mark as best answer if the above helps....!!!