【发布时间】:2020-05-02 04:50:21
【问题描述】:
下面是触发器更新附件或文件插入的字段,有人可以为这个触发器建议一个测试类吗?
请有人帮忙为下面的触发器编写一个@isTest 类来实现 100% 的代码完成
trigger ContentDocumentLinkTrigger on ContentDocumentLink (after insert) {
if(trigger.isAfter) {
if(trigger.isInsert) {
ContentDocumentLinkTriggerHandler.onAfterInsert(trigger.new);
}
}
}
这是课程
public class ContentDocumentLinkTriggerHandler {
public static void onAfterInsert(list<ContentDocumentLink> lstCntLinks) {
set<Id> setTaskIds = new set<Id>();
list<task> lstTask=new list<task>();
Id recordTypeId = Schema.SObjectType.Task.getRecordTypeInfosByName().get('ERT_Task_Record_Type').getRecordTypeId();
for(ContentDocumentLink clIterator : lstCntLinks) {
setTaskIds.add(clIterator.LinkedEntityId);//Set all task id
}
if(!setTaskIds.isEmpty()) {
lstTask= [SELECT Id, Name,Attachment_Indicator__c FROM task WHERE Id IN :setTaskIds and recordtypeid=: recordTypeId ]; //Get all the task
}
for(task varTsk: lstTask){
varTsk.Attachment_Indicator__c=true;//Set Attachment Indicator Flag true
}
if(lstTask.size()>0){
update lstTask; //update task
}
}
}
提前致谢。 卡罗琳
【问题讨论】:
标签: salesforce salesforce-lightning