function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sandeep medikondasandeep medikonda 

Time Based Workflow Rule vs Apex Scheduled Jobs

What is a better choice from the design and stability perspective for a below requirement.

When a Lead record exists in the system, based on the RecordType we should change the status of the Lead record type during the below timelines.

1. When Lead Created Date is more than 91 days old and stage='Prospecting' change status from Attempting to Interim Purge
2. When Lead Created Date is more than 98 days old and stage='Prospecting' change status from Interim Purge to Final Purge.

Volume of Leads created are 500-2000 leads per day.
pconpcon
Personally I think Apex Scheduled Jobs using Relax [1] is the way to go.  If you do native scheduled jobs then you can run into deployment issues with the class changing and having to stop the job.  If you use time based workflows then you can run into even nastier problems deploying if you try to make any changes to any other workflows for the object.

[1] https://github.com/zachelrath/Relax
Shashi PatowaryShashi Patowary
Hi Sandeep,

If anything can be achieved without using Apex, that config component should be always  preferred. For you case, it seems it can be achieved by a Time based workflow. For more information on time based workflow please refer to this -

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

Please let me know if this is helpful.

regards,
Shashi

 
sandeep medikondasandeep medikonda
Hi Pcon & Shashi,

I wrote both Apex Scheduled Job which can execute this functionality & also created Time Based workflow rule to compare. I am seeing that the Time based workflow rule is having more cons than pros. Like the individual record which satisfies the criteria will be put in a Queue and since the time line is 91 days. The record will be in the queue for 91 days until it gets executed. while 2000 new records are created everyday which can satisfy the criteria.

I am concerned that having the record being evaluated against the workflow criteria everytime its created or updated might influence the processing time.(like records taking more time to save). 

If i see the debug log. i can see the trace of all workflow rules on the object getting triggered when i do an action(kind of makes u not to prefer time based workflow rule concept altogether).

I am going forward with the Scheduled jobs for now. Both your suggestions were helpful in making my decision.

Thanks,
Sandeep.
Edward EncarnacionEdward Encarnacion
Config vs. Dev is much more nuanced than that I think.

Have to agree with PCon here, seems like a pretty simple logic that the perceived advantages of using timebased workflows is trumped by the potential issues that time-based workflows pose especially with that volume of leads. With this requirement, think its actually much easier to visualize this as a scheduled job. I look at Time-based workflows as only useful when say, sending email reminders, creating tasks after N amount of days but once youre dealing with actually trying to do what looks like batched updates of data. I think scheduled jobs are the way to go.