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

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

  • Wow. Talk about a totally vague documentation! Thanks. – Mossi Mar 19 '15 at 0:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.