Salesforce Scheduled Batch Apex

Scheduled Apex is a super useful system in that permits a developer to write some batch apex code and execute that code at scheduled times. This is incredibly useful because salesforce triggers and workflow rules can only execute as the related record is saved. A salesforce Time Based Workflow rule can fire based on hours or days from some date or time on the record, but its functional capabilities are fairly limited (create tasks, send an email to a limited set of recipients, update a field on the associated record). 

Sometimes you need to take action at some point that is completely independent of the record being saved. A "Scheduled Apex Batch" can solve this problem.

Here is an example: A response is required by a support rep at a given date/time for a case submitted by a client. The "Response Required By" is a time previously calculated, but can't be used by the standard SLA system in SF. Therefore, we need a way to look at all the open cases every few minutes and send notification to the case owner if the Response Required By is about to expire. 

You may also be wondering: "how frequently can I schedule an apex batch to run in" 

A scheduled apex can be scheduled to run at most once every one hour. 

Big HOWEVER; but you can have 12 schedules for the same Apex Class to run every hour. So you can schedule it to execute at the 0 minute of the hour, 5th minute of the hour, ….., 55th minute of the hour. So effectively, the most frequent execution of a given class is "every five minutes".

However there are other limitations that need to be noted:
- Salesforce only adds the process to the queue at the scheduled time. Actual execution may be delayed based on service availability – So, the interval between two subsequent email notifications may be less than 5 minutes.
- You can only have 25 classes scheduled at one time – You will be left with only 13 schedules for other requirements

You may also want to consider the limits on the no. of emails that can be sent per day.

Other Scheduled Batch Apex Application Examples:

- Check all your open opportunities once a day and remind users to update those past their close date
- Find all the open opportunities where there is not an open task for followup and create that task
- Send an email to clients automatically with open balance statements
- Send an email reminder to all clients with whom you have an appointment the following day
- Send an email reminder to all your traveling sales reps every day with a reminder of their upcoming appointments (or send a reminder to them after their appointments to update the opportunity with the results of their meeting with the client)
- Data cleanup: run a batch each day to look for and notify owners of duplicates
- oh, about a thousand others - you can take pretty much any operation you care to on your data stored in salesforce and create other records, make notifications, create tasks, kick off integrations - you name it. 

If you have an idea for a project like this and want to get it developed for your organization, we can help! Our developers produce systems like this every day. Contact us if you'd like to discuss your project, get an estimate, and get it produced. You can reach us at