when i update a single record from UI..the trigger fires properly and does it thing but when i use data loader to update 1200 records then trigger is not fired for all records.

The IF condition is getting true but not executing the method when using data loader.

if(Trigger.isAfter && trigger.isUpdate){
   set<Id> sL = new set<Id>();
        for (lead l : trigger.new) {
            if ((l.field0__c != trigger.oldMap.get(l.Id).field0__c) 
                    || (l.field1__c!= trigger.oldMap.get(l.Id).field1__c) 
                    || (l.field2__c!= trigger.oldMap.get(l.Id).field2__c) 
                    || (l.field3__c!= trigger.oldMap.get(l.Id).field3__c)) {
        if (!sL.isEmpty()) {

  • Does your trigger have any exclusion logic based on an integration or data-load user/profile? Is ClassName.Metod() properly bulkified? – David Reed Mar 7 '18 at 22:19
  • Hi @David Reed No exclusion Logic. The trigger works well with single record update from UI. And Yes method is bulkified. – Dnyaneshwar Mar 7 '18 at 22:35
  • if data loader transaction size > 200 (you would have to alter this in settings) and you are using some static vbl for trigger recursion control, then records 201+ may not be processed due to static vbl value – cropredy Mar 7 '18 at 23:12

This code is properly bulkified, and should work on bulk updates. Note that the trigger only does additional work if one of the four fields are actually updated. Check your data and make sure that records are actually changing.

  • Yes...I am changing the the field3__c and yes i can see the record is getting modified using last modified date time – Dnyaneshwar Mar 7 '18 at 22:18
  • @Dnyaneshwar != is case-insensitive, by the way, so if you're just changing capitalization, it won't count as a change in this code. – sfdcfox Mar 7 '18 at 22:20
  • No i am changing values...like form xxxx to yyyy – Dnyaneshwar Mar 7 '18 at 22:36
  • @Dnyaneshwar You're missing something, then, or you've oversimplified the code example. This should work correctly. – sfdcfox Mar 7 '18 at 22:38
  • okay..i will use debug.....Initially i thought i made any silly mistake. Thanks for the help – Dnyaneshwar Mar 7 '18 at 22:49

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.