On the first of January we had an issue where a lot of Contracts passed their end date. This caused a time-dependent workflow to fire, but there were so many occurrences (15000+) that it took a very long time. In the future we expect this number to increase greatly.

I'm wondering whether my plan to use the Apex Scheduler and turn this into a (reoccurring) batch job is a good idea? And in a more generic sense, what would determine whether to use a time-based workflow or a batch job for actions like these?

2 Answers 2


Scheduled apex jobs are the only time-based alternative for time-based workflows within the SFDC platform currently. So your idea of moving to scheduled apex is the way to go.

As a general way of making the decision between the 2, I'd say use time-based workflow unless you run into its limitations, including (but not limited to) the following:

Time triggers can't reference the following: DATE or DATETIME fields containing automatically derived functions, such as TODAY or NOW. Formula fields that include related-object merge fields.

Salesforce limits the number of time triggers an organization can execute per hour. If an organization exceeds the limits for its Edition, Salesforce defers the execution of the additional time triggers to the next hour. For example, if an Unlimited Edition organization has 1,200 time triggers scheduled to execute between 4:00 PM and 5:00 PM, Salesforce processes 1,000 time triggers between 4:00 PM and 5:00 PM and the remaining 200 time triggers between 5:00 PM and 6:00 PM.



The Limitations of "Time Trigger Workflows" are well documented here:

  1. We cannot use the Time dependent Workflow if the option is set to "Every time a record is created or edited." This would be one of the biggest drawbacks to consider moving to Scheduled Batch.

  2. Also, Salesforce Limits the amount of "Time Triggers" per Hour. Salesforce Processes 1000 times triggers per hour. But the amount of records which can be processed per trigger is not documented (At least i was not able to find one).

  3. If you are expecting more records to fall under the your criteria, it is safe to write Batch Class and Schedule them on daily basis to check the criteria. It provided flexibility and bigger batch size for processing.

    Batch Process can process upto 50 Million records. So it would be safe to take the Scheduled Batch approach.

  • 4
    There is a limit to the number of batches you can process. It is 250,000 per day minimum, or the number of active licenses times 200 if this result exceeds 250,000. This is at least 10 times more than timed workflow limit. The 1,000 triggers per hour should really read "1,000 records per hour". Workflow rules always evaluate on each record individually.
    – sfdcfox
    Commented Jan 6, 2015 at 16:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .