+ Start a Discussion

Trigger fails to update values using data loader

I am using a before trigger to update some values of Lead records. When loading Lead records I see that the records are NOT being updated thru the trigger whenever there is an error record in the upload list. If all records gets inserted successfully then the update happens fine but the updates doesnt happen when even one record fails to be inserted as part of the upload.


I checkd the debug logs and the trigger logic is executing fine. At the end of the trigger I see that the values are updated in the corresponding Lead records but the result doesnt have the updated values.


Any clues or ideas?




The Apex Data Loader, works in batches and failes the complete batch is any record in that batch fails. This is basically a property OptAllOrNone in DML statements in Apex code, which can be set for DMLOptions. But in Apex Data Loader I am not sure if any such property is there for the user to set.


For now, you can try by giving a batch size of 1, in Apex Data Loader Settings. This will ensure each record being processed irrespective of other records.


Hope this helps.


maybe you can put up your trigger code here?

ashish raiashish rai


Think you haven't written your code for bulkify trigger. So if you change the bactch size inside data loader to 1 your trigger will work fine. So may be when you are upload through data loader it hits the govener limit.


I agree with you about the batch size set to 1. But that is killing the whole purpose of bulk trigger, isnt it? The bigger confusion for me is that if one record has an error and it forbids update to the reset of the record fields then why do the records get inserted in the first place (Note: It is a Insert operation from Data Loader). The transaction should be atomic, its weird that insert happens but update of the field values thru trigger part fails.


Thanks for your input.

ashish raiashish rai


    Can you please post the code for update????