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
Thomas Schmidt 11Thomas Schmidt 11 

Can i Make sure that Records with a certain attriute are all within one batch and not spread across two batches in batch apex?

Hi, 
i have a Time-Tracking app in salesforce where users track their work in percent of their time per workday. i want to autocalculate the overhead ( 100 - actually tracked work form multiple records) every morning in a batch job.
Therefore i think it would be needed that all TimeTracking-records with the same employee and day have to be included in the same batch to compare everything and calculate the overhead. is There an option to make sure that, if for example 5 TimeTrackingrecords with the same employeee-entry and the same date exist, dont get spread over two batches?

best regards,
Thomas
Poornima HR 5Poornima HR 5
You may use Database.Stateful for this. Check this out - https://developer.salesforce.com/forums/?id=9060G000000XdkOQAS