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
Jag@SFJag@SF 

Simulated Deployment Failed

I'm using Change Sets to deploy an APEX Trigger into Production from a full Sandbox. After successfully uploading the trigger along with the test class into the production I ran a validation on the componets and got the following error.

  User-added image

TestSchedule.testScheduleDelete() Class 15  Failure Message: "System.AsyncException: The Apex job named "Nightly Order Delete" is already scheduled for execution.", Failure Stack Trace: "Class.ScheduleDelete.start: line 15, column 1 Class.TestSchedule.testScheduleDelete: line 91, column 1"

This Apex Job has got nothing to do with the trigger i'm trying to deploy. Do I need to delete all scheduled jobs before I import a custom apex trigger or class into production?

Is there a way I can disable the schedule jobs or than deleting it?

bob_buzzardbob_buzzard
Unforunately you have to delete the Apex job - there's not much to reinstate afterwards, so it could be worse.

As to why this is causing your deployment to fail, it usually means that there is another class that both your trigger and the scheduled job non-obviously rely on that has been changed.  For example, I have a single unit test fixtures class which all of my tests use to create data etc.  When I make a change to that, I have to delete my scheduled class as its at an older API version and the tests are colocated with the scheduled code, and thus I'm trying to change a class it depends on.
Jag@SFJag@SF
Thanks Bob. Just one more question I have a "global class NightlyOrderDelete implements Schedulable" and another class

global class ScheduleDelete
  {
  global void ScheduleDelete() {}
 
  public static void start()
  {
    NightlyOrderDelete d = new NightlyOrderDelete();
    String exp = '0 01 01 ? * *';
    System.schedule('Nightly Order Delete',exp ,d );
  }

But I could not figure out how the schedules are created without ScdeduleDelete class is referenced anywhere on the system. 

I'm little naive to system.schedule so can you tell me how the schedules are created or does salesforce automatically creates schedules when the system.schedule method is referenced in a class?
bob_buzzardbob_buzzard
There's more information on scheduling apex at:

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