2014-10-20 27 views
0

我在Salesforce方面遇到困難。如何撰寫觸發器以指定在「由...報告」字段中創建案例的人作爲記者?撰寫觸發器以提及某個案件的記者

這是代碼,我已經寫了:

trigger caseRepoter on Case (before insert) { 

    List<Case> cases = new List<Case>(); 

    for (Case cas: Trigger.New) { 
     if (cas.CreatorName != null) { 
     Case c = new Case(); 
     c.CreatorName = cas.Id; 
     cases.add(c); 
     } 
    } 

    insert cases; 
} 

`

提前非常感謝。

回答

0

SObjects有一個CreatedBy標準字段,它是創建該對象的用戶的查找。所以在你的foreach循環中,這將是cas.CreatedById

+0

我試過這個,但它沒有工作。 @robertpisano – user3482434 2014-10-21 18:10:43