Skip to main content

Facing issues in scheduling an apex class?

When trying to schedule an apex class, We are facing the scheduled apex exception 'Error: You must select an Apex class that implements the Schedulable interface.'


In our scenario, We have noticed that the class which we are trying to schedule is invalid. This was the reason for the above error.

Usually Classes and triggers are marked as valid, as long as dependent metadata has not changed since the class was last compiled. If any changes are made to Object names or Fields that are used in the class, including superficial changes such as edits to an Object or Field description, or if changes are made to a class that calls this class, the isValid flag is set to false.

From below query you can check which other classes or triggers are set as inValid:

  • Select Id, Name from ApexClass where isValid = false
  • Select Id, Name from ApexTrigger where isValid = false


Compiling all classes can fix this issue.  To compile Classes:

  • Go to Setup | Develop | Apex Classes  
  • For LEX - Setup | Custom Code | Apex Classes
  • Click 'Compile all classes' Link

The is the same fix to be followed incase your apex class is not showing in Schedule Apex after making a meta data change related to the schedule class.

I hope this article helps. Thanks for your time in reading this. Cheers :)

Comments