+ Start a Discussion
Igor FilatovIgor Filatov 

Scheduled class Bug

Hello to everyone, today I create Schedulable Apex class to send emails after 1 minute if trigger fire, i programmed callout as:
 

ScheduleCasePostWithFile scheduleMail = new ScheduleCasePostWithFile(C[0], F,'temp' + string.valueOf(DateTime.now()));
String CRON_EXP = string.valueOf(DateTime.now().addMinutes(2).format('s m h d M ? y'));
System.schedule('temp' + string.valueOf(DateTime.now()), CRON_EXP , scheduleMail);

But I am dealing with the problem "execution of AfterInsert caused by: System.AsyncException: Based on configured schedule, the given trigger will never fire. ()", if I change CRON_EXP to hardcoded nearest minute, all OK, so did anyone get this problem before and know how to deal with this?

Thanks.

Best Answer chosen by Igor Filatov
Alex EzhilarasanAlex Ezhilarasan

Hi Igor,

Use this format

String CRON_EXP = string.valueOf(DateTime.now().addMinutes(2).format('s m H d M ? y'));
Please do let me know whether this helps you

All Answers

Igor FilatovIgor Filatov
I confused, when I use format "H" and "h" (hour) mean different values, so "H" count hours from start of the day and "h" count hours from 0PM or 0AM, so it never be bigger than 12, that was hard de debug)
Alex EzhilarasanAlex Ezhilarasan

Hi Igor,

Use this format

String CRON_EXP = string.valueOf(DateTime.now().addMinutes(2).format('s m H d M ? y'));
Please do let me know whether this helps you
This was selected as the best answer
Igor FilatovIgor Filatov
Thank you) I deal with it on m own before read your reply, but it really kick me off about 20 minutes to debug..