You need to sign in to do that
Don't have an account?
jameskCA
How to invoke system.schedule
I'm trying to create a schedule to run an email class we have. I don't think I'm understanding the schedulable class and where / when you invoke the system.schedule method.
I have an email class that works fine if you run with execute anonymous.
I thought that would work, but nothing gets scheduled. Am I supposed to call the system.schedule from my email class? I'm just not sure how to actually schedule the job. Thanks in advance.
I have an email class that works fine if you run with execute anonymous.
CommissioningFollowup CF = new CommissioningFollowup();My scheduler class uses the following code:
global class SchedulerCommissioningFollowup implements Schedulable { global void execute(SchedulableContext SC) { SchedulerCommissioningFollowup SCF = new SchedulerCommissioningFollowup(); CommissioningFollowup CF = new CommissioningFollowup(); //Will Run Everyday at 00:00 (Midnight) String sch = '0 0 0 1/1 * ?'; String jobID = system.schedule('Commissioning Followup Job', sch, SCF); } }
I thought that would work, but nothing gets scheduled. Am I supposed to call the system.schedule from my email class? I'm just not sure how to actually schedule the job. Thanks in advance.
Change your schedule class as below
global class SchedulerCommissioningFollowup implements Schedulable
{
global void execute(SchedulableContext SC)
{
CommissioningFollowup CF = new CommissioningFollowup();
}
}
After this in developer console execute the below line of code to schedule your class
SchedulerCommissioningFollowup SCF = new SchedulerCommissioningFollowup();
//Will Run Everyday at 00:00 (Midnight)
String sch = '0 0 0 1/1 * ?';
String jobID = system.schedule('Commissioning Followup Job', sch, SCF);
Try the above mentioned steps and that should fix your issue.
Let me know in case of any other concerns.
Thanks
SchedulerCommissioningFollowup SCF = new SchedulerCommissioningFollowup();
//Will Run Everyday at 00:00 (Midnight)
String sch = '0 0 0 1/1 * ?';
String jobID = system.schedule('Commissioning Followup Job', sch, SCF);