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
JoeStolzJoeStolz 

Manually Run Scheduled Task from Dev Console

Can someone tell me how to run this scheduled job manually from the Developer Console?
global class ScheduleBatchCreateMonthlyCharges implements Schedulable
{
  public ScheduleBatchCreateMonthlyCharges() 
  {
    
  }

  global void execute(SchedulableContext SC)
  {
      Id batchInstanceId = database.executeBatch(new BatchCreateMonthlyCharges(), 1);
  }
}

Thank you
Best Answer chosen by JoeStolz
Amit Chaudhary 8Amit Chaudhary 8
Please check below post. I hope that will help you
1) http://amitsalesforce.blogspot.com/2016/02/batch-apex-in-salesforce-test-class-for.html

How to Schedule scheduler class
There are two option we have schedule the scheduler classes.
1) By System Scheduler.
2) By Developer console

System Scheduler.

Step 1) Click on Setup->Apex class. Then search Schedule Apex button.
Step 2) Select the scheduler class and set Time like below screen shot.

By Developer console 
Execute below code from developer console :-
 
ScheduleBatchCreateMonthlyCharges m = new ScheduleBatchCreateMonthlyCharges ();
String sch = '20 30 8 10 2 ?';
String jobID = system.schedule('Merge Job', sch, m);

Let us know if this will help you

Thanks
AMit Chaudhary


 

All Answers

Amit Chaudhary 8Amit Chaudhary 8
Please check below post. I hope that will help you
1) http://amitsalesforce.blogspot.com/2016/02/batch-apex-in-salesforce-test-class-for.html

How to Schedule scheduler class
There are two option we have schedule the scheduler classes.
1) By System Scheduler.
2) By Developer console

System Scheduler.

Step 1) Click on Setup->Apex class. Then search Schedule Apex button.
Step 2) Select the scheduler class and set Time like below screen shot.

By Developer console 
Execute below code from developer console :-
 
ScheduleBatchCreateMonthlyCharges m = new ScheduleBatchCreateMonthlyCharges ();
String sch = '20 30 8 10 2 ?';
String jobID = system.schedule('Merge Job', sch, m);

Let us know if this will help you

Thanks
AMit Chaudhary


 
This was selected as the best answer
JoeStolzJoeStolz
Thank you for the reply, Amit. The link to your blog helped and I found that I needed to run the following:
BatchCreateMonthlyCharges s=new BatchCreateMonthlyCharges();
DataBase.executeBatch(s);

Thank you again
Mukesh Kumar 107Mukesh Kumar 107
Run a Schedule Job NOW
 
ScheduleSalesTargets c = new ScheduleSalesTargets();
c.execute(null);
 
OR
 
Check the Time Now, if it is, let's say 10:39 AM, in your clock then set the minute to 41. This will schedule the job for 10:41 AM just two minutes from now. But, if you set minute value to 38, then it will schedule to next hour 11:38 AM
 
ScheduleSalesTargets c = new ScheduleSalesTargets();
String sch = '0 0 * * * ?';
System.schedule('Sales Target Job11',  '0 41 * * * ?', c);