global class OrdertoZhaoEmailBatch implements Database.Batchable { //给赵新安总监发邮件,更改他的IS_8_Sendemail__c字段的真或假,联合'发送邮件给赵新安总监'的工作流。 private List idList = null; global OrdertoZhaoEmailBatch() { } global OrdertoZhaoEmailBatch(List temp) { idList = temp; } global Database.QueryLocator start(Database.BatchableContext bc) { if(idList != null && idList.size()!=0){ // return Database.getQueryLocator([select CreatedDate,Low_profit__c,LS_Big_amount__c,IENDTANI_Big_amount__c,RVI_Big_amount__c, // Whether_the_mhbs__c,IS_8_Sendemail__c,Is_TAX__c // from Order // where (Low_profit__c = true or LS_Big_amount__c = true or IENDTANI_Big_amount__c = true or RVI_Big_amount__c = true) // and Whether_the_mhbs__c = false and ApproveStatus__c = 'OrderPass' // and CreatedDate >= 2021-04-01T00:00:00.000+0000 // and Id in :idList]); return Database.getQueryLocator([select CreatedDate,Low_profit__c,LS_Big_amount__c,IENDTANI_Big_amount__c,RVI_Big_amount__c, Whether_the_mhbs__c,IS_8_Sendemail__c,Is_TAX__c from Order where Id in :idList]); }else{ return Database.getQueryLocator([select CreatedDate,Low_profit__c,LS_Big_amount__c,IENDTANI_Big_amount__c,RVI_Big_amount__c, Whether_the_mhbs__c,IS_8_Sendemail__c,Is_TAX__c from Order where (Low_profit__c = true or LS_Big_amount__c = true or IENDTANI_Big_amount__c = true or RVI_Big_amount__c = true) and Whether_the_mhbs__c = false and ApproveStatus__c = 'OrderPass' and CreatedDate >= 2021-04-01T00:00:00.000+0000]); } } global void execute(Database.BatchableContext BC, list scope) { List updatetfList = new List(); for(Sobject obj : scope){ Order oer = (Order)obj; if(oer.IS_8_Sendemail__c == false){ oer.IS_8_Sendemail__c = true; updatetfList.add(oer); } } if (updatetfList.size() > 0) update updatetfList; } global void finish(Database.BatchableContext BC) { } }