
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