New answers tagged

3

I wouldn't say this trigger is production ready. Couple of things I can recommend are. Move the SOQL and DML outside for loop. Add error handling for SOQL and update. Do not write logic inside triggers. Read this document and Force.com enterprise architecture book if you have some time. Add comments about the functionality.(Personal choice)


6

No, you have not properly bulkified your code. Bulkification 101's most important lesson is to aggregate filter values, query before your loop and put records into a Map, and update values after your loop. Set<Id> sponsorshipIds = new Set<Id>(); for (Opportunity record : trigger.new) { sponsorshipIds .add(record.Sponsorship_Contract__c); } ...


Top 50 recent answers are included