1

创建记录时,我正在尝试在自定义对象(Work_order__c)上制作记录副本。我认为这很接近,但我不确定我错过了什么。

这有效:

trigger CloneWorkorder on Work_Order__c (after insert) {

    List<Work_order__c> CaLNewList = new List <Work_Order__c>();

    for (Work_order__c WorkOrder : Trigger.new) {
        if (workorder.CreateCopy__c) {
            CaLNewList.add(new work_order__c(
                               case__c = workOrder.case__c));
        }
    }
    insert  CaLNewList;

}
4

1 回答 1

0

如果您需要更改某些信息,可以使用此信息

trigger CloneWorkorder on Work_Order__c (after insert) {

    List<Work_order__c> CaLNewList = new List()<Work_order__c>;

    for (Work_order__c WorkOrder : Trigger.new) {
        CaLNewList.add(new work_order__c(case__c = workOrder.case__c));
    }

    insert  CaLNewList;

}

或者如果您需要完全相同的副本

trigger CloneWorkorder on Work_Order__c (after insert) {

    List<Work_order__c> CaLNewList = trigger.new.deepClone();
    insert  CaLNewList;

}
于 2014-01-20T17:13:44.563 回答