You need to sign in to do that
Don't have an account?
VN
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 = Trigger.new; 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> (); try { 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; rec=rec.substring(0,15); if(rec.equals('012200000004Tsn')) acnt1.Target_Visit__c=mas2.Potential_Customer__c; else if(rec.equals('012200000004Tss')) acnt1.Target_Visit__c=mas1.Existing_Customers__c; 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
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!!!
Regards
Priya Nair
This is not a bug in the Force.com 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.