Please check out below thread to get idea over implementation on above request: https://salesforce.stackexchange.com/questions/134268/how-to-schedule-my-batch-class-on-click-on-button-in-vf-page/134324
Hope above information helps. Please mark as Best Answer so that it can help others in future.
what you can do is call apex controller from VisualForce page and in apex class schedule the apex batch class=>
global class BatchClass implements Database.Batchable<sObject>, Database.Stateful {
global Database.getQueryLocator start(Database.BatchableContext bc)
{
return Database.getQueryLocator([data you want to fetch using query]);
}
public void execute(Database.BatchableContext bc, list<object> objlist)
{
}
public void finish(Database.BatchableContext bc)
{
}
}
apex controller to execute batch
BatchClass bc= new BatchClass (); Database.executeBatch(bc,/*batch size*/); // call this controller on your VisualForce page.
If you find your solution mark this as the best answer.
Please check out below thread to get idea over implementation on above request:
https://salesforce.stackexchange.com/questions/134268/how-to-schedule-my-batch-class-on-click-on-button-in-vf-page/134324
Hope above information helps. Please mark as Best Answer so that it can help others in future.
Thanks.
In this example where is scheldulingjobs controller
Greeting!
Try this:
what you can do is call apex controller from VisualForce page and in apex class schedule the apex batch class=>
apex controller to execute batch
BatchClass bc= new BatchClass ();
Database.executeBatch(bc,/*batch size*/);
//
call this controller on your VisualForce page.
If you find your solution mark this as the best answer.
Thank you!
Regards,
Suraj Tripathi