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?
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.