0

According to SF if we use the Database class to issue a DML command:

instead of exceptions, a result object array (or one result object if only one sObject was passed in) is returned containing the status of each operation and any errors encountered

I am still getting exceptions when I call Database.update(objs, false): System.SObjectException: DML statment cannot operate on trigger.new or trigger.old

Why is that?

1 Answer 1

1

The documentation refers to DML exceptions; those exceptions that happen while the query is running.

You are getting an SObjectException since you are trying to apply a DML operation on the trigger.new list. This list can only be read. The exception is being thrown before the DML actually begins, therefore not ignored by Database.update().

Hope that helps,

Luis Luciani

1
  • Wow. Talk about a totally vague documentation! Thanks.
    – Mossi
    Mar 19, 2015 at 0:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .