[SalesForce] Time-dependent workflow vs Apex Scheduler

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?

Best Answer

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.

https://help.salesforce.com/HTViewHelpDoc?id=workflow_time_action_considerations.htm&language=en_US

Related Topic