System.FinalException:SObject行不允许错误

时间:2015-06-29 19:00:43

标签: exception triggers salesforce apex

以下代码段位于Opportunity afterUpdate触发器中。我试图更新那些受影响的机会的帐户,并在获得DMLException后,代码进入catch块我得到

  

' System.FinalException:SObject行不允许出错'在行a.Id.addError(de.getMessage());

请告诉我a.Id.addError(de.getMessage());

行的问题
if (acctLst.size() > 0) {
   try{
       update acctLst;
   } catch(Exception de) {
       for (Account a : acctLst) {
           a.Id.addError(de.getMessage());
       }
   }
} 

1 个答案:

答案 0 :(得分:0)

您正尝试将错误添加到 sObject字段 a.Id,但应将错误添加到sObject中

a.addError(de.getMessage());