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

Trigger Issue
Hello,
I created the trigger below to create a new Opportunity when an existing Opportunity reaches the Closed Won stage. I have 2 issues.
1) On the line where I create the new Opportunity's name, the Account Name from the previous Opportunity is not coiming through.
2) The trigger is actually creating 4 Opportunities instead of just 1.
Does anyone know how to fix these? Thanks,
I created the trigger below to create a new Opportunity when an existing Opportunity reaches the Closed Won stage. I have 2 issues.
1) On the line where I create the new Opportunity's name, the Account Name from the previous Opportunity is not coiming through.
2) The trigger is actually creating 4 Opportunities instead of just 1.
Does anyone know how to fix these? Thanks,
// Automatically create an open renewal Opportunity trigger RenewalOpp on Opportunity(after update) { List<Opportunity> newOpp = new List<Opportunity>(); for (Opportunity opp : Trigger.new) { IF(opp.StageName == 'Closed Won'){ Opportunity renewalOpp = opp.clone(false); renewalOpp.Name = opp.Account + ' - Renewal (' +opp.Renewal_Date_Year__c + ')'; renewalOpp.StageName = 'Active Discussions'; renewalOpp.CloseDate = opp.Renewal_Date_Next__c; renewalOpp.Amount = opp.Amount; renewalOpp.Effective_Date__c = opp.Renewal_Date_Next__c; renewalOpp.Renewal__c = 'Yes'; renewalOpp.Renewed_Opportunity__c = opp.Id; renewalOpp.Probability = 5; newOpp.add(renewalOpp); } } IF(newOpp.size() > 0) insert newOpp; }
All Answers
For the second issue, there may be other triggers in your org that is cause recursion. Setup debug logs to trace.
2) It's probably because of workflow field updates, which cause the trigger to be run again. You can confirm this in the debug log.