I am trying to call the system.schedule method in a generic manner to help avoid scheduled job naming confusion like so:
// Set my schedulable class to run.
private String setMyClassRunning(String jobName, String sch){
SchedulableClass sc = new SchedulableClass();
String scheduledId = scheduleJob(jobName, sch, sc);
return scheduledId;
}
// Set a scheduled job to run. This function has been isolated to account for test scenarios.
// If this method is called in a testing context, then add "Test" to the job name to avoid conflicts
// with already scheduled jobs.
private String scheduleJob(String jobName, String cronExpression, Object schedulableClass)
{
if(Test.isRunningTest())
{
jobName = 'Test' + jobName;
}
return system.schedule(jobName, cronExpression, schedulableClass);
}
However, when I try and save the code, I get the error "Method does not exist or incorrect signature: system.schedule(String, String, Object);
This is confusing as the system method descriptions clearly show that this method does exist.
I know that it is possible to schedule a job using the method on an individual class basis, but the point is I want to make this generic, so I don't have to re-write the testing name convention code every time. Can anyone help??