function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Trigger firing but not updating records inserted with Data Loader

I have an insert trigger that performs extra validation and sets the value of several other fields. The trigger works fine from the UI. Nevertheless, when inserting records with the Data Loader the trigger is firing and the validation is performed (I can see the error messages in the error file), but records successfully inserted have null value for the other fields that are set in the trigger. Can anyone tell me why this is happening? Is there a setting to get the Data Loader to work the way I want?
would you mind posting examples of the errors being logged, and also what your code does to handle them?
Here's psuedo-code for my insert trigger on a custom object, MyObject__c with Apex class MyObjectInitializer
for (MyObject__c obj : {
Decimal x = MyObjectInitializer.calculateX(obj);
Decimal y = MyObjectInitializer.calculateY(obj);
Decimal z = x+y;
// Validation - error message appears on page layout or in the error file when using Data Loader
if (z != obj.Z) {
   obj.Z.addError(z+' does not equal '+x+' plus '+y+'.')
// Setting the field value, does not seem to work when inserting a record from the Data Loader
// i.e. obj.W is null
i'll have to defer to someone more skilled on the trigger side of things unfortunately.
Ron WildRon Wild
You may be hitting governor limits.  If the transaction fails, all database changes will be rolled back.

Try setting your batch size to a smaller number in the data loader so that your bulk inserts include fewer records for each transaction.