Is it possible to set the StartTime
and EndTime
fields of a CronTrigger
object ?
I'm not able to set this fields in Apex code, I have the error below :
Field StartTime is not writeable
I know I can do it directly in CRON expression but only for simple expression.
For example, if I want to schedule a job every Monday at 2:00PM between 23th March 2015 and 12th January 2016, how can I do it with a CRON expression ?
When I schedule an APEX class in Salesforce GUI, I can choose the startTime and EndTime, so I think it's possible !
Any ideas ?
Best Answer
Lets say you want to schedule a class which run from 20-August-2015 to 30-August-2015 daily at 7 AM. Cron expression would be:
Lets say you want to schedule a class which run from 20-August-2015 to 20-August-2016 daily at 7 AM. Cron expression would be:
Cron for running a batch every Monday at 2:00 PM is
You can not write directly to fields. You will have to reschedule the class and delete old schedule.