+ Start a Discussion
kittu9kittu9 

Apex Class Scheduling for every two weeks

Hi Team,

 
  Please help how to schedule a apex class to run for every 2 weeks.
 
 

There are seven fields for Salesforce’s cron syntax, unlike *nix’s 5 fields.

  • Seconds [0-59]
  • Minutes [0-59]
  • Hours [0-23]
  • Day of month [1-31]
  • Month [1-12 or JAN-DEC]
  • Day of week [1-7 or SUN-SAT]
  • Year [1970-2099]

I seen above two but am not getting how to schedule it for 2 weeks please help me on that. thanks in advance

 

 

 

AKS018AKS018
First schedule your Schedule class, for 1st day of every month by using Standard functionality which is given in salesforce. Then for next schedule i'e after 14 days on 15the of month. So for second scheduling through your class Schedule as like below.

public static String CRON_EXP = '0 0 0 15 * ? *';


global static String scheduleIt() {
scheduledMonthly sm = new scheduledMonthly();
return System.schedule('Monthly Reconciliation', CRON_EXP, sm);
}

The above code has to place in your Class where the functionality is goingon
kittu9kittu9

what abt for the first scheduling how to do it? Can you please help me on that how to do

kittu9kittu9

'0  0 12 1 * ? ' Is this correct to run the apex class  for 1st day of every month by using Standard functionality. If yes what have to do the next step?

AKS018AKS018
for first scheduling so to apex classes ---> There you will find Schedule Apex button. Click on it. then Set the frequency