You need to sign in to do that
Don't have an account?
Will Yee
Trigger Inserts new Opp after old Opp changes Stage to Closed Won
Hi, currently the trigger is creating two duplicate Opportunity records instead of a single one. I have disabled all other triggers on the Opportunity object, but I still can't see to see why this would be creating two instead of one on Stage change.
Would love to see if someone could take a quick look and point me in the right direction
Would love to see if someone could take a quick look and point me in the right direction
trigger insertNewOpp2 on Opportunity (after update) { //create list of Opps List<Opportunity> listOpp = new List<Opportunity>(); for(Opportunity opp : Trigger.new) { //if Opp is changed to Closed Won if(opp.StageName == 'Closed Won') { //Create a new opp with the following attributes Opportunity oppNew = new Opportunity (AccountID=opp.AccountID, StageName='Prospecting', Primary_Contact__c=opp.Primary_Contact__c, LeadSource=opp.LeadSource, ForecastCategoryName='Omitted', Name=opp.Name + 'New', CloseDate=opp.CloseDate, RecordTypeId = '012d0000000SocP'); //Add to the list listOpp.add(oppNew); } } if (listOpp.size() > 0) insert listOpp; }
Here is an example on how to prevent recursive triggers:
http://help.salesforce.com/apex/HTViewSolution?id=000133752&language=en_US (http://help.salesforce.com/apex/HTViewSolution?id=000133752&language=en_US)
All Answers
Here is an example on how to prevent recursive triggers:
http://help.salesforce.com/apex/HTViewSolution?id=000133752&language=en_US (http://help.salesforce.com/apex/HTViewSolution?id=000133752&language=en_US)