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
Comments
Post a Comment