You need to sign in to do that
Don't have an account?
Bhavneesh Saluja
Scheduling normal Apex Class
Can I schedule a normal apex class which has few batch classes executed within it? For Ex:
public class A{
//Some Code....
BatchCLass B= new BatchCLass();
Database.executebatch(B,200);
Batchcls C= new Batchcls();
Database.executebatch(C,200);
//Some Code...
}
Now i want to write a scheduler class for Apex class A. Will normal Scheduler class work for this scenario or is there any restriction from Salesforce on this.
Any leads would be appreciated.
Thanks in Advance !!!
public class A{
//Some Code....
BatchCLass B= new BatchCLass();
Database.executebatch(B,200);
Batchcls C= new Batchcls();
Database.executebatch(C,200);
//Some Code...
}
Now i want to write a scheduler class for Apex class A. Will normal Scheduler class work for this scenario or is there any restriction from Salesforce on this.
Any leads would be appreciated.
Thanks in Advance !!!
You will need to implement the scheduler interface in the class, like this:
You can then use anonymous Apex to schedule the class like this:
Hope this helps!
Best regards,
Martijn Schwärzer
All Answers
You will need to implement the scheduler interface in the class, like this:
You can then use anonymous Apex to schedule the class like this:
Hope this helps!
Best regards,
Martijn Schwärzer
Thanks for the reply. However, I was thinking of doing something like this:
Let this class be a standalone piece. And write a scheduler for this:
Please let me know if this would be a feasible solution to my problem stated, since i want Class A to be a standalone piece of code which i can execute from Trigger as well as scheduler class based on certain critera.
Regards
Bhavneesh
If you want Class A to be a standalone piece, then your solution is perfect!
Happy coding!
Best regards,
Martijn Schwärzer
Ps. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.