Batch InsertError Notification

I am using batch insert service. If one of my record fails, I need to catch it and include its ID in the error email. But as of now, I am not able to point out to a particular errored out record. I need help on building logic for this issue.

Abhijeet,

I don’t think its good idea to have a batch insert and catch the failed record ID’s in the error e-mail. Instead what you can do is…

Loop over the records, have a try-catch block with in the loop. In the try block, insert the record, if it fails the control goes into the catch block, append this particular record to some errorRecordList. After the final iteration of the loop and coming out of loop, you can have all the record ID’s from errorRecordList and send a single e-mail with all the failed records.

Be careful in using the Try-Catch block within the loop.

Thanks,
SATYA.

Yes,this is the better approach for handling the kind of task narrated,we also used the same kind of logic for getting failed ID’s and generate an email alerts to the users.

HTH,
RMG