2

I have a Trigger On OpportunityLineItem when it's get updated, it will update the Opportunity. I need to update OpportunityLineItem in Bulk. For that, Using Dataloader I kept the (batch size =200) of DataLoader and Used DML below.

if(oppListToUpdate.size() > 0) Database.update(oppListToUpdate, false);

It working with batch size =200, But when any record of that batch fails to update due to validation error, all records in that batch fail. How to solve this issue? Please Help!

  • in short: I believe standard apex dml has the database option AllOrNone set to true, you can overwrite this by using the database class. – Samuel De Rycke Dec 15 '15 at 14:21
  • It looks like he already set false. Below those statements are you looking into exceptions count and throwing user defined exception to rollback the transaction ? – munimanjunath Dec 15 '15 at 14:24
  • Share all the relevant code from the trigger, and and handlers/helpers – Brian Mansfield Dec 15 '15 at 14:30
2

In my experience, the way that the Data Loader works is that it will process a batch (defined by the batch size in the Data Loader settings) until it encounters the first error. After Data Loader encounters an error, it gives up on the rest of that batch.

From reading the Data Loader documentation (link points to the Winter '16 version of the docs), it doesn't appear that this behavior can be changed.

Having the Database.update(oppListToUpdate, false) in your OpportunityLineItem trigger isn't going to help in this case, because it doesn't/can't change the behavior of the Data Loader itself.

The only workaround that I can offer is to decrease the batch size in the Data Loader to reduce the number of records that are incorrectly being flagged as failures. That should give you a manageable number of failures to investigate (and then insert/update those through other means).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.