Jobs Cannot Be Scheduled in Sandbox After Refresh - Getting Error: The Apex job named "JOBNAME" is already scheduled for execution.
Last updated 2017-10-14 ·Reference W-3852346 ·Reported By 52 users
Summary
Jobs Cannot Be Scheduled in Sandbox After Refresh - Getting Error: The Apex job named "JOBNAME" is already scheduled for execution.
Setup - Monitor - Jobs - Scheduled Jobs shows no jobs scheduled.
Reason: The job name is stored in CronJobDetail. The Scheduled Apex Cron Job Detail records are still being copied to sandbox copies.
Repro
In a newly refreshed sandbox, make sure there is no scheduled apex job by going to Setup - Monitor - Jobs - Scheduled Jobs
Then execute following command in the Execute Anonymous area:
Scheduler.get('JOBNAME').runDaily(0);
Error: The Apex job named "JOBNAME" is already scheduled for execution.
Workaround
Until that bug is fixed, this can be solved in any of the following ways:
1) Call Support each time this occurs to have Support run the scrutinies
2) Delete/abort the Scheduled Apex job before doing the sandbox copy, and then restart it after the sandbox copy is completed. That will work because when a Scheduled Apex job is deleted, we also delete its CronJobDetail record. There are two ways to do this:
> Setup => Monitor => Jobs => Scheduled Jobs; find the job; click on the "Del" link for the job
> System.abortJob()
3) Use a unique job name. For example, add a datetime string to the end of the job name so that it is always unique
Reported By (52)

















Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.