Skip batch job if running

16 views Asked by At

I have two batchable apex scripts that create a dataset for reporting. The first walks through a custom object clearing some data elements. The second walks through assignments to accumulate new values for the custom object elements. I have a button on the custom object tab for the users to initiate the process manually and it is scheduled to run at night as well. Occasionally a user will initiate the process via the button while it is still running resulting in corrupted data. I am looking for the best method to stop the first job from running if either of the two jobs are still running. Both jobs are Batchable contexts and I am having difficulty how to create a flag and reset it when completed. I would appreciate any and all suggestions.

0

There are 0 answers