[SalesForce] Execute a schedulable class from execute anonymous window

I'm having trouble executing a schedulable class from the execute anonymous window.
I used to used the following format:

QA_Biemanal s=new QA_Biemanal();
s.execute(null);

For some reason it's not working anymore. I'm receiving the following error:`

Line: 1, Column: 15
Method does not exist or incorrect signature: new QA_Biemanal()

This method worked just fine before the new update rolled on the sandbox.

My schedulable class is as follows:

global class QA_Biemanal implements Schedulable {
global void execute(SchedulableContext SC) {

UserRole      Role  = [SELECT Id from UserRole where Name='Success Manager'];    
List<User>    us    = [Select Id, Name, UserRoleId From User Where IsActive=True And UserRoleId =: Role.Id];


    Integer i;
    integer j; 
    integer mod;
    DateTime dia; 
    String num_dia;

    for (User Usu: US)
    {

     List<Account> accts = [SELECT Id, Name, OwnerID, Ninja__c from account where Cliente_Activo__c=True AND OwnerId=:Usu.id];

        i = 0;
        j = 1;

     For (Account acc: accts)
     {

        dia     =   Date.today()+i;
        num_dia =   dia.format('u');

        if (num_dia=='5'){
            i = i + 2;
        } else if (num_dia=='6'){
            i = i + 1;
        }



        Task t= new task();
        t.Subject       =   'QA Bisemanal';
        t.ActivityDate  =   Date.today()+i;
        t.Description   =   'Realizar el QA de todas las actividades de tu cuenta';
        t.Status        =   'Open';
        t.WhatId        =   acc.Id;
        t.OwnerId       =   acc.Ninja__c;
        t.Priority      =   'Normal';
        t.Contrase_a_Adwords__c  =   num_dia;

        Task ta= new task();
        ta.Subject      =   'Sync Bisemanal';
        ta.ActivityDate =   Date.today()+i;
        ta.Description  =   'Ponerse en contacto con el cliente para seguimiento';
        ta.Status       =   'Open';
        ta.WhatId       =   acc.Id;
        ta.OwnerId      =   acc.OwnerId;
        ta.Priority     =   'Normal';
        ta.Contrase_a_Adwords__c  =  num_dia;

        insert ta;                                
        insert t;

        mod = math.mod(j,2);
        if (mod==0){
            i++;
        }
        j++;
     }

    }


}

}

What am I doing wrong here?

Best Answer

I believe the syntax you're looking for is:

Id jobId = System.schedule('NameOfScheduledJob', CRON_STRING, new SchedulableClassName());

Related Topic