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
Ajay Kumar 261Ajay Kumar 261 

Bulk update: Before Trigger is not firing for all the records.

Hi,

I have a method which will update a field on contact record. As you can see the code below, this method runs on before trugger on contact and then it will update the Merchant Score field. It is is working fine when I update in the UI. However it is not working when I do the bulk update using dataloader and informatica load. it is updating only few records. 

Scenario1: I tried updating 209 records without bulk API, and it worked only for 193 records.
Scenario2: I tried updating 100 records with bulk API, and all of them are success.
Scenario3: I tried updating 150 records with bulk API, and all of them are success.
Scenario4: I tried with 200 records with bulk API, however only 100 got updated.

There is no consistency in the output. Can anyone help me to resolve this?

public static void contactMSScoreUpdate(List<Contact> ContactTriggerList,Map<Id,Contact> OldContactTriggerMap){
 
           for(Contact c : ContactTriggerList){
                      Contact con= OldContactTriggerMap.get(c.Id);
                     if(c.Score_Merchant__c != null&&c.Score_Merchant__c!=con.Score_Merchant__c&&c.score_profile__c!=null){  
                             c.Score_Merchant__c = c.score_profile__c+c.Score_Merchant__c.right(1);
                             system.debug(' c.Score_Merchant__c '+ c.Score_Merchant__c );
                         
                     }
                    
          }
  }

Regards,
Ajay
Best Answer chosen by Ajay Kumar 261
Ajay Kumar 261Ajay Kumar 261
I came to know that becaue of BulkAPI records were getting skipped.

Regards,
Ajay

All Answers

Sudipta DebSudipta Deb
Hi Ajay -

Your code looks good to me. Are you sure that all of the data inserted will pass the below condition -
if(c.Score_Merchant__c != null&&c.Score_Merchant__c!=con.Score_Merchant__c&&c.score_profile__c!=null)
Ajay Kumar 261Ajay Kumar 261
Yes. I am making sure that data is correct.
Ajay Kumar 261Ajay Kumar 261
I came to know that becaue of BulkAPI records were getting skipped.

Regards,
Ajay
This was selected as the best answer