You need to sign in to do that
Don't have an account?
flewells
Help bulkifying my trigger
I am looking for helping bulkifying a trigger I wrote that updates the Owner on Account. I understand the concept of bulkifying and tried reviewing other posts where people have requested similar help, but am at a loss. I'm a beginner and learning and happy to just have created the trigger below...any help in bulkifying is appreciated. Also, does bulkifying this trigger mean that the test class I wrote also needs to be updated?
trigger UpdateOrganizationOwner on Account (before insert, before update) { for (Account a : trigger.new) { if (a.RecordTypeId == '012000000000000'&& a.RM_ID__c!=null) { a.OwnerId = a.RM_User_ID__c; } } }
All Answers
- It is always good practice to create more than 1 test record(Upto 200 records or so) and using asserts in test classes, This will help you to validate if your trigger is butlkified in your test class itself(Once you run it, you will get error if it is not bulkified - Using asserts).
There is no SOQL in the TRIGGER hence no need to take extra care . Please avoid hard coding of Ids
Thanks to all of you for the tips. I realized I don't need select the RecordType after all, so that simplified it even further.