sunxia
2022-04-18 7290aa76586b4222c121ddbaea3e1f18202a6e85
force-app/main/default/classes/AgencyShareUpdateBatch.cls
@@ -30,6 +30,16 @@
    }
    global void finish(Database.BatchableContext bc) {
        // 如果前一个603的batch正在等待状态,则取消掉前一个batch的执行
        List<AsyncApexJob> lstJobs = [SELECT Id FROM AsyncApexJob WHERE (Status = 'Queued' OR Status = 'Holding') AND ApexClass.Name = 'NFM603Batch'];
        for (AsyncApexJob job : lstJobs) {
            try {
                System.abortJob(job.Id);
            } catch(Exception ex ) {
                System.debug(ex);
            }
        }
        Id execBTId = Database.executebatch(new NFM603Batch(),1);
    }
}