You need to sign in to do that
Don't have an account?
Jefe55
Apex update trigger not working using Apex Data Loader
I have a trigger set up on an object to trigger after an update. If I do the update manually it works just fine. However, if I do a mass update using the Data Loader the trigger doesn't get invoked.
Is there a way to force the trigger while using the Apex Data Loader?
Try this:
All Answers
The trigger should still fire fine when you are loading from the loader.
Was the trigger set up to handle batch record processing? Could be that it is actually only firing for the first record in your batch, and it just seems that it isn't working.
You need to handle an array of the trigger objects and process each one.
Post your trigger code if you want anyone to take a look at it.
The trigger should still fire even if you use the data loader. The only way batch updates are not handled would be if
> you have used a check like If(Trigger.New/Old.size()==0)
> Or you would have hardcoded 'Trigger.New/Old[0]'
In the first case, the trigger will not get executed when you do a batch update. In the second case, only the first record in the batch gets processed through the trigger.
How would you go about modifying for batch?
I have a simple trigger to update a field:
}
rigger TaskRegion on Task (before insert, before update) {
String locale = [Select Region__c from User where id = :Trigger.new[0].OwnerId][0].Region__c;
Trigger.new[0].Assigned_Region__c = locale;
Thanks!
Something like this should work.
Thanks!!
I do still get an error though:
Save error: Illegal assignment from LIST<User> to MAP<Id,User>
Thanks for your help!
Do I have to create a list first?
Thanks!!!
-Justin
Try this:
Thank you!!!
I have started with the Force.com Workbook to learn more APEX, are there any other resources you can suggest?
Thanks again!
That is a good start, use the Cookbook examples from this site, and Google when you have questions. There are many excellent blogs out there on this topic.
My triggers and classes are all built bulk-safe and even handle cases where there might be concurrent updates. If you require insight to my code I am happy to post it as an answer and further detail of what I'm trying to do in the code.
Did anyone else experience problems with that?
@Roger Wicki
No idea if you'll ever see this, but FWIW, I had similar issue with a trigger on opportunity. If your trigger has a DML statement, you could hit the governor limit with a data loader batch of 200. I believe the governor limit is 150, which may be why it works with a batch size of 100.
If anyone knows how i can get dupecatcher to fire via data loader, that'd be amazing!!
Thanks for the notice. My trigger indeed has a DML statement, but so far I was in the strong believe that the batch size for DML was 200 as well... According to the limits page, 150 is the limit of allowed DML statements per transaction. That would almost mean I'd have a DML in a loop. If that'd happen, I would also have to receive an error message for limits exceeded.
If by dupecatcher you mean Salesforce's built in duplicate detector, mine is working. I sometimes get errors in Data Loader if it detects duplicates. My duplicate rules are set up to completely block however. Maybe warnings don't work.