You need to sign in to do that
Don't have an account?
SFDCCrystalCo
Apex Trigger Bulkification
I am trying to get some understanding of when to bulkify code.
My trigger below executes a simple field update when an Account value is changed - no other objects involved here.
I have inserted 600+ Accounts in my Sandbox and subsequently updated these same records with no issues using Data Loader.
That said, do I need to 'bulkify' this code any further?
trigger AccountAllowTransfer on Account (before update)
{
for (Account a : Trigger.new)
{
if (a.Producer__c == null)
{
a.Allow_Transfer__c = 'Yes';
}else{
a.Allow_Transfer__c = 'No';
}
}
}
My trigger below executes a simple field update when an Account value is changed - no other objects involved here.
I have inserted 600+ Accounts in my Sandbox and subsequently updated these same records with no issues using Data Loader.
That said, do I need to 'bulkify' this code any further?
trigger AccountAllowTransfer on Account (before update)
{
for (Account a : Trigger.new)
{
if (a.Producer__c == null)
{
a.Allow_Transfer__c = 'Yes';
}else{
a.Allow_Transfer__c = 'No';
}
}
}
your code is prefect. Nothing you need do for Bulkification. If you want to create Trigger frame work then you can see code in below blog:-
http://amitsalesforce.blogspot.in/2015/06/trigger-best-practices-sample-trigger.html
Please let me know if this will help you.
Thanks
Amit Chaudhary