/** * Ver1.0 2022-05-17 ssm * * OBSAP项目-报价委托功能修改 * * after update: * 报价委托已完成时,查询标准任务里关联的未完成任务,并更新状态 */ public without sharing class QuoteIraiHandler extends Oly_TriggerHandler { private Map newMap; private Map oldMap; private List newList; private List oldList; public QuoteIraiHandler() { this.newMap = (Map) Trigger.newMap; this.oldMap = (Map) Trigger.oldMap; this.newList = (List) Trigger.new; this.oldList = (List) Trigger.old; } protected override void afterUpdate() { task_changeto_finish(); } // 报价委托已完成时,查询标准任务里关联的未完成任务,并更新状态 private void task_changeto_finish() { List ids = new List(); // 循环获得已完成的报价委托 for (QuoteIrai__c irai : this.newList) { QuoteIrai__c irai_old = this.oldMap.get(irai.Id); if (irai_old != null && irai.QuoteIrai_Status__c != irai_old.QuoteIrai_Status__c && irai.QuoteIrai_Status__c == '更新完毕') { ids.add(irai.Id); } } if (ids.size() > 0) { List tasks = [select Id, Status, QuoteIraiId__c from Task where Status != '完了' and QuoteIraiId__c in :ids]; if (tasks != null && tasks.size() > 0) { for (Task task : tasks) { task.Status = '完了'; } update tasks; } } } }