问题
I wrote this APEX class and sheduled it to run every day.I don't get an error message, but unfortunately the class doesn't do anything... Can anybody help me out?
global class CustomersDateCheck implements Schedulable {
global void execute(SchedulableContext sc) {
List<Customers__c> CustomerList = [SELECT Id FROM Customers__c];
DateCheck(CustomerList);}
public static void DateCheck(Customers__c[] objects){
for(Customers__c obj: objects){
if(obj.DateField > Date.today()){
continue;}
else{obj.FlowUpdateHelper__c = true;}
}
}
}
回答1:
you write the Schedulable now you need Schedule it.
run this 3 line of code in developer console then check apex jobs
//will run daily at 13:00
CustomersDateCheck m = new CustomersDateCheck();
String sch = '0 0 13 * * ?';
String jobID = system.schedule('Customers Date Check Job', sch, m);
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm
回答2:
The error means you're trying to access something that you didn't include in the query, in this case the Customers__c.DateField__c , you need to either remove the reference to that, or update your query to include that info
来源:https://stackoverflow.com/questions/62002277/i-sheduled-an-apex-class-to-run-everyday-but-nothing-happens-can-somebody-help