How should I efficeintly handle addError() errors when using Database.update(obj[],false) from the code?
They are all failing as they are hitting addError() in all of the 3 attempts. Is Database.update(obj[], false) not suitable with addErrors()?
After working on the issue for quite some time, I decided to use a boolean to ignore the validation errors so as not to encounter addError() from the trigger. Is this the correct approach?
Let's take an example of 5 records out of which the first 3 consecutive records throw addError().
- Database.update(obj[],false) First attempt: hits the error at the 1st record and deletes it from the array of records for retrying. The array for the retrial has 4 records out of which 2 would fail.
- Database.update(obj[],false) Second attempt: Fails again at the first record and deletes it. The array now has 3 records out of which 1 would fail again.
- Database.update(obj[],false) Third attempt: Fails again at the first record and rollsback the updates on the whole array as Database.update(obj[], false) only tries 3 attempts before failing.