+ Start a Discussion
davidgillendavidgillen 

Schedulable class is unschedulable

I have an unusual problem. I  have developed an Apex class which implments schedulable.  I go into Setup -> Develop -> Apex Classes -> Schedule Apex and fill in the form. Now, when I'm selecting the class I just press the icon to give me a list and it only returns the one class which implements schedulable, which would appear the smart way of letting you select the class.

 

However, I get the following error -

Error: You must select an Apex class that implements the Schedulable interface.

 

I'm really baffled by this, see code below.

 

global class TimesheetWeeklyJob implements Schedulable{
    global void execute( SchedulableContext SC ) {
        WeeklyTimesheetProcess.markSubmitted();
        WeeklyTimesheetProcess.createNewSheets();
    }
}

 

tmatthiesentmatthiesen

When did you receive this error?  On save of the schedule?  I can't seem to reproduce.  Just curious, if you saved the class with a different name and tried to schedule it, what happens?

davidgillendavidgillen

Yes, it was on the save that I received the error. I renamed the class to TimesheetWeeklyJob2 and it scheduled correctly. I then renamed it back to TimesheetWeeklyJob, and it also scheduled correctly. I now have a solution, although am somewhat more baffled than before.

oski1993oski1993

I've seen something similar. My solution was to make the class inactive, then switch it back to active. 

 

I think there might be a bug in the scheduling implementation somewhere...

tmatthiesentmatthiesen

We will try to repro at HQ.  Let me know if you find a repro.

 

t

oski1993oski1993

I'd found it to be very intermittent...

crop1645crop1645

Yes, this is very odd.

 

  1. I had a schedulable class 'Foo'  that had executed once but the schedule called for no more executions
  2. I wanted to reschedule the class to run again (I had deployed some new Apex code in related classes)
  3. Setup | Monitoring | Scheduled Jobs only lets me cancel or delete. I selected Delete
  4. Then, when I went to Setup | Develop |  Apex Classes | Schedule Apex, the class 'Foo' is not found in the list of schedulable classes ?!?
  5. I noticed my Apex schedulable class was marked as Valid 'unchecked'

I went to the help and Community forums looking for answers, found this thread, then went back to SFDC..

 

Lo-and-behold, after the passage of time (20 minutes) , the class had been marked as valid and could be found as a schedulable class in the 'Schedule Apex' user interface.  There was no action I took either in deployment, the admin Setup options, or anything. 

 

Without better information, it would appear that something in the background runs at SFDC cloud that re-enables schedulable classes after either their previous schedule is deleted and/or an intervening deployment of referenced classes has occurs.

nickwick76nickwick76
I had the same problem. I also noticed that the classes that I should be able to schedule but couldn't were unchecked as Valid. What I did was to open the class list (App Setup -> Develop -> Apex Classes). Then I clicked on the classes one by one that I had problems with, then I went back (with the browser back button) and could see that the class was marked as valid again. When it is Valid it should be possible to schedule it again. At least this worked for me.

// Niklas
MJ Kahn / OpFocusMJ Kahn / OpFocus
This happened to me after I deployed a class that my Schedulable class was dependent on. I went to Apex Classes and clicked Compile All Classes. After that was done, Salesforce successfully recognized my Schedulable class as schedulable.
Andrew MagruderAndrew Magruder
I had the same intermittent problem.  A fix that worked for me is, in Setup

Expand Develop in the left pane.
Click on 'Apex Classes'
There's a link at the top left "Compile All Classes"

After I did the above (in a new browser tab), I was able to schedule my class.
zoranszorans
I had the same problem today. All my classes that are implementing schedulable interface were active but I still couldn't see some of them. Then it crossed my mind that before deploying I checked this new option in Deployment Settings: Allow deployments of components when corresponding Apex jobs are pending or in progress.
Caution: Enabling this option may cause Apex jobs to fail.

so I unchecked it again and after that I was able to schedule my class through an schedule apex UI form.
Don't know if this is normall behaviour or a bug but it solved my problem
KKRKKR
I had the same issue on one of my sandbox that was recently refreshed. Thanks Andrew, I compiled all classes and was able to see my class listed in the schedulable classes for selection while scheduling an apex job.

KKR.