I have written a Page and Controller which update a field in all Person Accounts in my org using a batch process. This is only meant to be done once a year. Is there a way I can record the last time the code was run, and warn someone if they do it too soon after the last time?


You could store every execution in a some sort of "Log" object, and query that object before the execution.

  • Once you have a log object like this, it becomes useful in many ways. You can use it to track when a batch process last ran - and also capture some stats from that run. I use it to track who uses a certain "mark problem solved" button. I also use it to flag missing attendance and when the missing attendance is resolved. I could go on. – Jagular Apr 22 '15 at 15:34

I actually used a Custom Setting which has just one record with one field which is the last time the code was run.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.