function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

before trigger- partial success

if you have an adderror method in a before trigger, will it exist the entire batch if 1 record calls the adderror? if so, how can you partially process those records with an explicit database.update method


If the update is executed using the update statement, like


update listOfRecords;

 then addError on arecord will cause a ValidationException.


However if you update using 

Database.SaveResult[] results = Database.update(recordsToUpdate, false);

 then there will be no exception and you will have a chance to examine the results array.


Hope this helps,

Apex Editor LS - free alternative to apex editor.

Bhawani SharmaBhawani Sharma
You can not do partial insert/update in trigger context. But what all you can do it, use try catch statement and add the error in some field .

Just few additions!


  • addError method prevents any database operation(due to which trigger spawned) to happen and rollbacks the DML action(due to which trigger spawned), and throws a error msg to the UI. 
  • If you have any other DML statement in your trigger like say "insert Contact" the trigger successfully process that.
  • I dont think you can stop a single record from insertion using addError.
  • You cannot use Database method in trigger context to prevent or block records DML