Posts

Showing posts from December 11, 2018

How to capture individual exceptions in bulk record updates

Image
up vote 2 down vote favorite Today I am writing an apex class to transform a bulk set of data from one record to another. During the course of this transfer, it is expected that we will have errors on the records in the system. What we would like to do if an error is found, is mark the record as error, and add the exception that caused the error to field on the record. We would then like the class to continue to process records. What I am unable to figure out at this time, is how do I capture the exception of the record in error, and toss it into our error bucket, without stopping the process of the remainder of the records or hitting any limits? My first thought was to insert all the records into a list, and then go through each record attempting an insert in a try catch block. I then realized this would still be in danger of h...