0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Caseを複製するトリガー

Last updated at Posted at 2022-08-25

回答を得たら即消している。

まぁ、おかげでただでさえ嫌いな外国語が不信感が芽生えたので余計に嫌いになります。英語嫌いがどんどん進みますね。

消されちゃったけどコードは残っているので、ここに記録しておきます。
テストクラスまで準備したんだけどなぁ。 こいつの質問位は二度と答えないです。

trigger CaseTrigger on Case (After insert,After update) {
    
    List<Case> insertCaseList = new List<Case>();
    
    if (Trigger.isInsert || Trigger.isUpdate) {
        for (Case c : Trigger.new){

          if ( c.Status =='Closed' && c.Accept_Solution__c) {

              Case ca = new Case();
              ca.subject = c.subject;
              insertCaseList.add(ca);
          }
            
        }
    }
    
    system.debug(Logginglevel.INFO,'-- insertCaseList.size()  ' + insertCaseList.size() );    
    if ( insertCaseList.size() > 0) insert insertCaseList;    

}
@isTest
public class CaseTrigger_test {
    
    @isTest
    public static void test01() {
        
        Test.startTest();
        
        Case ca = new Case();
        ca.subject ='test';
        ca.Status ='Closed';
        ca.Accept_Solution__c = true;
        insert ca;
        
        //System.assertEquals(ContactList[0].OwnerId, u.Id);
        
        Test.stopTest();
        
    }    
    
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?