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
kevincckevincc 

CronTrigger StartTime and EndTime

Hi,

If you look at the CronTrigger object description there are fields called StartTime and EndTime:  http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_crontrigger.htm

 

It appears these fields are NOT writable.

 

 Using System.Schedule (http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm) method does not accept start time or end time for a cron job.  This means any job scheduled through System.Schedule has StartTime as the current date/time and EndTime is null.

 

How does one set CronTrigger StartTime and EndTime fields for jobs scheduled using System.Schedule?

 

 

Thanks!

LeeSeiferLeeSeifer

String sch = '0 0 1 * * ?'; <== This will start the Job at 1 AM everyday.
String jobID = system.schedule('Merge Job', sch, m);

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm

You have to look at this section: to know about the time pattern

 

Using the System.Schedule Method

kevincckevincc

Thanks.

 

But how do you use system.schedule to only run the job from 10/22/2013 to 10/22/2014 ?

Through the schedule apex screen in the salesforce setup menu it is possible to set starttime and endtime.  It appears system.schedule is lacking support for specifying CronTrigger.StartTime and CronTrigger.EndTime.

 

Can salesforce product management please confirm?

kevin lamkevin lam

Use 2013-2014 in the parameter for the year.

LeeSeiferLeeSeifer

There is no way to modify a Schedule job right now even in setup page. 

 

The only way to modify the Job is that you have to delete the existing one and then reschedule it with other expression.

 

You can specify the range of years you want to schedule.

 

"0 0 1 3 */3 ? 2013-2015" <<-- this will run the job at 1 AM third day of every 3 months from 2013 to 2015.

 

Hope this help

kevincckevincc

The issue I have is that the fields CronTrigger.StartTime and CronTrigger.EndTime are not exposed via System.schedule.  The fields cannot be updated using APEX / SOQL either.

 

These fields can be specified when sheduling a job in the salesforce UI.

 

 

I added a comment to the existing idea: https://success.salesforce.com/ideaView?id=08730000000g9BmAAI