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
lavan llavan l 

Regarding rolling back whole batch job

I want to rollback whole batch process when single record in any batch gets failed. I want to know how to use DML options optallornone property in batch...........
By default the opt all or none, is defaulted to false. Meaning if a dml statement with a List<SObject> fails, all of the rows are failed. So if you wrap the dml statement in a try catch, you can supress the exception, and fail the entire batch, without failing the batch process, and log the exception. Alternatively, though I can't confirm this, because I haven't done a bath process in a while, if the dml statement throws an exception, that may only bubble up the single batch, not he process, also giving you the desired functionality.