I am trying to connect specific records that fail to delete in my batch job to their error messages. I thought my solution was working, but I checked the size of .getErrors() and it's size 1. My test class is set up so 50 records fail, so I would think the size of .getErrors() would be 50. How is the .getErrors() array populated?
Best Answer
When you are calling Database.delete it is returning a List of Database.DeleteResult records if you are doing it to a list.
There are several things that could cause only 1 record to be returned here.
1) If you are calling Database.delete inside a query on each individual record, you will only get 1 error returned.
2) You are looking at a single result instead of all of the results.
It's harder to tell for sure what is going on though unless you show us what you have done.