You need to sign in to do that
Don't have an account?

Need Help Bulkifying my Trigger
Currently have the following trigger which works perfectly for one record inside our production organization:
trigger createCommissionClosedWon on Opportunity ( before insert, before update) { Opportunity[] opps = Trigger.New; for (Opportunity o:opps){ If (o.StageName == 'Closed Won') CreateCommissionRecords.createCommissionRecords(opps); }}
I'm trying to bulkify this trigger so that it performs well under bulk updates..... The following code creates an error when I try and save:
trigger createCommissionClosedWon on Opportunity (before insert, before update) { for (Opportunity opps: Trigger.New){ If (opps.Stage == 'Closed Won'){ CreateCommissionRecords.createCommissionRecords(opps); }}}
What am I doing Wrong??? This is the error message that I'm receiveing: Save error: Method does not exist or incorrect signature: CreateCommissionRecords.createCommissionRecords(SOBJECT:Opportunity)
it sounds like a variable / definitional problem.... Thanks so much for helping me.....
Hi,
Can you please post the CreateCommissionRecords class here?
I am not sure what you're trying to do in the CreateCommissionRecords class, but if you want to bulkify, then create a list of type Opportunity, after doing all the changes to the records ,add that record to the list and then update the list outside the forloop. SOmthing like this if I am doing all my processing in my trigger itself:
Hope this helps!
-sam
All Answers
Hi,
Can you please post the CreateCommissionRecords class here?
I am not sure what you're trying to do in the CreateCommissionRecords class, but if you want to bulkify, then create a list of type Opportunity, after doing all the changes to the records ,add that record to the list and then update the list outside the forloop. SOmthing like this if I am doing all my processing in my trigger itself:
Hope this helps!
-sam
Again just recently morphed this code to take the SOQL insert function out of the FOR LOOP, but any suggestions would be very much appreciated. Newby to Java and Apex... Thank you so much junglee for your help!!
I'm not entirely sure, but it looks like your createCommissionRecords is expecting an array of opp's and you are trying to pass in a single object instead of an array.
Thank you, did not realize you could make changes directly within a trigger... haha silly me.
This all works now........