I have a Schedulable class named 'DeletarSemCheckinSchedule' that runs some DML's. i also have another Schedulable class named 'AgendarSchedulesCheckin'. The 'AgendarSchedulesCheckin' should be called by itself every hour and the 'DeletarSemCheckinSchedule' should be called sometimes by 'AgendarSchedulesCheckin' either.
If I call the 'AgendarSchedulesCheckin' inside Developer Console with the code bellow the job is executed, but both 'DeletarSemCheckinSchedule' and 'AgendarSchedulesCheckin' aren't called again.
AgendarSchedulesCheckin abc = new AgendarSchedulesCheckin();
abc.execute(null);
AgendarSchedulesCheckin:
global class AgendarSchedulesCheckin Implements Schedulable {
global void execute(SchedulableContext sc)
{
Datetime horaAtual = datetime.now();
Date dataAtual = horaAtual.date();
Integer horaJob = horaAtual.hour();
Integer diaJob;
Integer mesJob;
//Integer minute = horaAtual.minute();
if(horaJob == 23){
dataAtual = dataAtual+1;
horaJob = 0;
}else{
//minute += 2; -- para teste
horaJob += 1;
}
diaJob = dataAtual.day();
mesJob = dataAtual.month();
String cron_exp = '0 40 '+horaJob+' '+diaJob+' '+mesJob+' ?';
String jobName = 'jobTeste';
System.Schedule(jobName, cron_exp, new AgendarSchedulesCheckin());
PredialReservas__c PredialReservas = new PredialReservas__c();
PredialReservas = [SELECT MinutosCheckin__c FROM PredialReservas__c WHERE Name = 'configBasica'];
Integer tempoParaCheckin = (Integer) PredialReservas.MinutosCheckin__c;
Integer tamanhoFor = (60/tempoParaCheckin);
Integer minutoAux = 0;
for(Integer x = 0; x < 3; x++){
cron_exp = '0 '+minutoAux+' '+horaJob+' '+diaJob+' '+mesJob+' ?';
jobName = 'jobTeste '+x;
System.Schedule(jobName, cron_exp, new DeletarSemCheckinSchedule());
minutoAux += tempoParaCheckin;
}
}
}
Can anyone help me to fix this?
Thanks in advance.