Skip to main content
Dave Smith a posé une question dans #Data Management
Would someone help with checking the following apex code. I need the scheduled job to run every month from 25th day until the end of each month. It should udpate the picklist field called "Status Indicator":

 

global class MyJob implements Schedulable {

 

   public void execute(SchedulableContext ctx)  {

 

    List<Project__c> projs = new List<Project__c>();

 

    for(Project__c p : [SELECT Last_Status_Report__c, Status_Indicator__c FROM Project__c]){

 

     

 

if (p.Last_Status_Report__c.month() == Date.Today().month()) {

 

        

 

  p.Status_Indicator__c = 'Green';

 

      } else

 

{

 

         p.Status_Indicator__c = 'Red'; }

 

      }

 

      projs.add(p);

 

    }

 

    update projs;

 

}

 

MyJob m = new MyJob();

 

    String sch = '0 0 0 25-31 * ? ?';

 

    String jobID = system.schedule('Last 5 days in month', sch, m);

 

}
2 réponses
  1. 8 sept. 2014, 21:32
    I don't know if the last part of the code is correct. 
0/9000