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
Baylor PeakBaylor Peak 

How to get records updated/created since the last executed Apex batch job completed?

Hello all,

Trying to find a clean method via SOQL to query only records that were updated/created since the last executed apex batch job completed?

We are hoping not to have to create a custom object to do this and looking for a clean way if possible:)

ANUTEJANUTEJ (Salesforce Developers) 
Hi Baylor,

Although there could be multiple ways to implement this scenario one way I could think of is to have a field that updates the batch number with the batch id the record belongs to and in case if the batch id matches in the query it can be queried via soql.

In case if this helps in your implementation can you please choose this as the best answer so that it can be used by others in the future.