You need to sign in to do that
Don't have an account?
System.Schedule To Run More Than One Hour From Now
Hi,
I have a requirement in a test class to execute a System.Schedule for more than one hour past the current time. I've tried the following but it's failing to run more than one hour from now. It's as if it runs within the current hour
String hourNow = ('' + System.Now()).substring(11,13);
Integer hourNowPlusTwo = Integer.valueof(hourNow) + 2;
Test.startTest();
String scheduleTime = '1 1 ' + hourNowPlusTwo + ' * * ?';
System.schedule('Run Cleanup', scheduleTime, CleanupCLass);
Test.stopTest();
I'm new to Scheduling. If I want to edit the above to 2 hours from now then if you know of the changes I need this would be appreciated.
Thanks in advance.
String scheduleTime = '0 00 '+(System.Now().hour()+2)' '+System.Now().day() +' '+System.Now().month()+' ?';
PS : just wrote this on notepad.