function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Scheduling apex class using class id

Hi , 


I have a requirement where in i need to schedule more than one apex class using system.schedule. The problem with system.schedule is that it takes class name as its one of the parameters. I have many apex classes so i dont need a class name. Instead is there any way to schedule an apex class using class id in system.schedule method...


The following is the code i m referring to


TestScheduledApexFromTestMethod s = new TestScheduledApexFromTestMethod();
system.debug('------------000000000000000--------------' +s);
String sch = '0 10 * * * ?';
system.schedule('one', sch,s);


Here i need to give the class name time and again and it kind of becomes static.

I need to schedule the apex class in a more dynamic way using class id . 

is there any alternate solution to schedule more than one apex class with one system.schedule method


The scheduled apex functionality works on a single class, so if you want to schedule multiple classes, you'd need to execute multiple schedule calls.


However, there is nothing to stop your scheduled class from taking more than one action - for example, kicking off more than one batch Apex job.