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
Derrick Abbey 9Derrick Abbey 9 

Can't schedule apex in UI

Hi Everyone,

I'm new to Apex and I'm trying to schedule a class that I've written.  I'm going into Setup > Develop > Apex Classes and clicking on the "Schedule Apex button.  When I select my class I get an error that says "You must select an Apex class that implements the Schedulable interface."  The thing is, I thought I followed the develper documentation correctly in setting this up.  I can't figure out why it's giving me this error.  Can anyone offer some assistance?  Here's my class:
global class autoRenewalOpps Implements Schedulable {
    global void execute(SchedulableContext sc) {
    public void aRopps() {
        //Create list of renewal opportunities to close
    	List<Opportunity> renewalOpps = [SELECT StageName, Type
			FROM Opportunity
			WHERE RecordTypeId = '012S00000000klc'
			AND IsClosed = False
			AND Type = 'Renewal'
			AND CloseDate < LAST_N_WEEKS:2
			AND LastActivityDate < LAST_N_WEEKS:2
    	//Loop through opportunities changing the type and stage
    	for (Opportunity opp : renewalOpps) {
        	opp.type = 'Auto-Renewal';
        	opp.StageName = 'Closed Won';
        //Update the opportunities
        update renewalOpps;
And here's the error I get when trying to schedule it:
User-added image

Thanks for any help.
Alba RivasAlba Rivas
I just copied your class into my org and it worked.

Maybe you can try in a different org? It's weird what is happening to you. Sorry I can't help more.
Derrick Abbey 9Derrick Abbey 9
Thanks Alba,

I copied this into my developer org and it worked as well.  So at least I know it's not something with my code.  I'll keep poking around.  I wonder if the fact that it's in a sandbox has anything to do with it.
Alba RivasAlba Rivas
Does your sandbox user have a salesforce license? Other licenses don't have access to opportunity (salesforce platform, for example)
Derrick Abbey 9Derrick Abbey 9
My sandbox user is an administrator.  I have access to all objects and fields in the sanbox.