0

I'm having an issue executing a schedulable class.

My Schedulable Class:

global class Recordatorio_Cobro implements Schedulable {
    global void execute(SchedulableContext SC) {
        Recordatorio_Cobro_Clase.Recordatorio();
    }
}

My apex class:

public class Recordatorio_Cobro_Clase {
    
    Public static void Recordatorio(){
        List<Account> acct         = [Select Id From Account Where Cliente_Activo__c = TRUE];
        UserRole      RoleAsist    = [SELECT Id from UserRole where Name='Asistente Administrativo'];
        UserRole      RoleAdmin    = [SELECT Id from UserRole where Name='Directora Administrativa'];
        User Asistente             = [Select ID From User Where UserRoleID=:RoleAsist.Id and IsActive = TRUE];
        User Admin                 = [Select ID From User Where UserRoleID=:RoleAdmin.Id and IsActive = TRUE] ;
        list<Opportunity> opp;
        List<Factura__c>  fac_Vencida;
        List<Factura__c>  fac_Abierta;
        
        integer Facturas_Vencidas;
        integer Facturas_Abiertas;
        

        DateTime dia     =   Date.today();
        String num_dia   =   dia.format('u');
       
        
        for (Account acc : acct){
            Facturas_Vencidas = 0;
            Facturas_Abiertas = 0;
            opp = [Select Id From Opportunity Where AccountId =: acc.id];
            for (Opportunity op: opp){
                fac_Vencida = [Select Id, Estado_de_Factura__c From Factura__c Where Estado_de_Factura__c = 'Abierta/Vencida' and Opportunity__c =: op.id];
                fac_Abierta = [Select Id, Estado_de_Factura__c From Factura__c Where Estado_de_Factura__c = 'Abierta' and Opportunity__c =: op.id];
                Facturas_Vencidas  = Facturas_Vencidas + fac_Vencida.size();
                Facturas_Abiertas  = Facturas_Abiertas + fac_Abierta.size();

                
            }
                
            If (Facturas_Vencidas==0 && Facturas_Abiertas>0 && num_dia=='7' ){
                
                    Task t= new task();
                    t.Subject       =   'Cobrar al cliente';
                    t.ActivityDate  =   Date.today();
                    t.Description   =   'Contactar al cliente para recordarle que tiene una factura abierta e intentar cobrarle';
                    t.Status        =   'Open';
                    t.WhatId        =   acc.Id;
                    t.OwnerId       =   Asistente.id;
                    t.Priority      =   'Normal';
                    
                    insert t;
                
            }

            if (Facturas_Vencidas>0){
                
                Task t= new task();
                    t.Subject       =   'Cobrar al cliente';
                    t.ActivityDate  =   Date.today();
                    t.Description   =   'Contactar a cliente MOROSO para cobrarle';
                    t.Status        =   'Open';
                    t.WhatId        =   acc.Id;
                    t.OwnerId       =   Admin.id;
                    t.Priority      =   'Normal';
                    
                    insert t;
            }
        }
    }
}

The command I use in execute anonymous windows:

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

And the error I receive is:

Line: 2, Column: 15

line 2:15 no viable alternative at character ' '

I have searched and can't seem to find the reason for this error. Could someone guide me in the right direction?

4
  • 2
    Did you copy paste this code from somewhere? It sounds like an invisible character messing things up.
    – Adrian Larson
    May 8, 2017 at 13:46
  • Yes I copied it from another working schedulable class I have. I've done this several times and never had an issue before. I also copied everything to word to check for any characters and can't seem to find any. Is there any possibility that the new summer update is messing with my classes? May 8, 2017 at 13:56
  • 3
    As a note, in my editing, I did remove what appeared to be a simple whitespace character between s.execute(null) and ; in the anonymous apex you're using. This would be the original character 15 on line 2 that the error message appears to be complaining about.
    – Derek F
    May 8, 2017 at 14:27
  • @DerekF Thanks Derek! That was the issue. Never thought it would be with the command on the execute anonymous window. May 8, 2017 at 14:40

0

You must log in to answer this question.

Browse other questions tagged .