You need to sign in to do that
Don't have an account?
Raghu Sharma 6
setting flag for batch run
I need to verify whether a batch (actually inbound email handler) has been run each day and if the batch is not run for a particular day, I need to send an email notification.
Is there any config way, I can set some flag before the anticipated time of batch run and reset the flag in batch.
After batch run anticipated time, I want to verify flag and if flag is not reset (which means batch did not run), I need to send an email
Is it possible to set the flag using workflow? Is it possible to verify flag and send email using workflow?
So, basically I'm trying to see if workflow can be run like a scheduled batch job for this simple task?
Is there any config way, I can set some flag before the anticipated time of batch run and reset the flag in batch.
After batch run anticipated time, I want to verify flag and if flag is not reset (which means batch did not run), I need to send an email
Is it possible to set the flag using workflow? Is it possible to verify flag and send email using workflow?
So, basically I'm trying to see if workflow can be run like a scheduled batch job for this simple task?
Using workflow could possibly be used but it sounds really messy and unreliable.
How is the batch called? if it's scheduled I would use Database.Stateful to keep track if there are any records sent to the execute method and then send an email from the finish method based on that,
When the inbound email handler is executed, does it create or update any records? if it updates a record can you add a date/time field to set when this class did it's update?
I would then look to create a scheduled class that looks for those records whos CreatedDate or update date/time falls within the required time frame, then send an email with the results, either it found some records or it didn't.
There are plenty of posts about creating a schedulable class, here's one to get you started,
https://salesforce.stackexchange.com/questions/80277/sample-code-to-schedule-an-apex-class
Once you've created the class to look up those records and send the email just go to Setup > Build > Develop > Apex Classes and click the 'Schedule Apex' button to schedule when your class should run