I sheduled an apex class to run everyday, but nothing happens. Can somebody help me out?

帅比萌擦擦* 提交于 2020-07-09 05:13:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!