我有一個基本的觸發器下面應該更新字段,最後會議日期,保存新事件後。該代碼在我的沙盒環境中正常工作,但它顯示0%的代碼覆蓋率,並且不允許我將其投入生產。任何幫助,將不勝感激。Salesforce事件更新父記錄(Apex後插入觸發器)
trigger createLastReviewDate on Event (after insert) {
//map object to store account id and task create date
Map<Id,Date> accIds = new Map<Id,Date>();
//iterate over the new triggers and get the account id and task create date
for(Event e : trigger.new){
accIds.put(e.AccountId,Date.valueOf(e.StartDateTime));
}
//get the accounts to be updated
List<Account> acctsToUpdate = [Select Id,Last_Meeting_Date__c from Account where id in:accIds.keySet()];
//update the custom date field
for(Account acc : acctsToUpdate){
acc.Last_Meeting_Date__c = accIds.get(acc.Id);
}
update acctsToUpdate;
}
我認爲這是一個簡單的觸發因素,並且隨着沙箱遷移到生產問題逐漸受到關注。目前沒有寫測試課,主要是因爲我不知道這是一個要求。 –