0

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)) {
                sL.add(l.Id);
            }
        }
        if (!sL.isEmpty()) {

            ClassName.Metod(sL);
        }                                                                   
 }
3
  • Does your trigger have any exclusion logic based on an integration or data-load user/profile? Is ClassName.Metod() properly bulkified?
    – David Reed
    Commented Mar 7, 2018 at 22:19
  • Hi @David Reed No exclusion Logic. The trigger works well with single record update from UI. And Yes method is bulkified. Commented Mar 7, 2018 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
    Commented Mar 7, 2018 at 23:12

1 Answer 1

2

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.

5
  • Yes...I am changing the the field3__c and yes i can see the record is getting modified using last modified date time Commented Mar 7, 2018 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
    Commented Mar 7, 2018 at 22:20
  • No i am changing values...like form xxxx to yyyy Commented Mar 7, 2018 at 22:36
  • @Dnyaneshwar You're missing something, then, or you've oversimplified the code example. This should work correctly.
    – sfdcfox
    Commented Mar 7, 2018 at 22:38
  • okay..i will use debug.....Initially i thought i made any silly mistake. Thanks for the help Commented Mar 7, 2018 at 22:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .