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

Problem With Triggers

Hi All,
I have written a trigger on Accounts(before insert,before Update). My problem is the trigger doesn't get executed when i use mass update of account records using data loader. But when i go to any account record and edit and save the record the trigger gets executed. The trigger is used to populate a field in the accounts page.
The code for the same is as shown.
trigger targetvisit on Account (before insert,before update) {   
Account[] acc =;
public Master_Data__c mas1;
public Master_Data__c mas2;
integer eve;
Set<String> acc1 = new Set<String> ();
Set<String> acc2 = new Set<String> ();
Set<Id> accid = new Set<Id> ();
  acc1.add('Existing Customers - CHAA');
  acc2.add('Potential Customers - CHAA');
mas1=[Select Existing_Customers__c from Master_Data__c where Name in :acc1];
mas2=[Select Potential_Customer__c from Master_Data__c where Name in :acc2];
for(Account acnt1:acc)
String rec=acnt1.RecordTypeId;
else if(rec.equals('012200000004Tss'))
acnt1.To_Be_Achieved__c=acnt1.Target_Visit__c - acnt1.Achieved__c;  

catch(Exception ex)

Please tell me where iam going wrong.
Thanks in advance
Priya Nair

It's a known bug. Execution of trigger is not consistant in case of bulk operation
Hi Naishadh,
Thanks for your help.
So is there no way to achieve it?
Please help.
Thanks again
Priya Nair
Perhaps you are having problems with Governor Limits.

Remove the try and catch block to know the actual error

Hi Sham,

Thanks a lot for your help again. I removed the try and catch block and got the errors. Now its working.

You are great!!!


Priya Nair



This is not a bug in the platform.  The trigger is being executed correctly, but a bug in the trigger (hidden by the try/catch) is preventing the message from being displayed.