function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nagesh ENagesh E 

Trigger is creating 2 opportunities on Lead Conversion if the Do not create opportunity is checked

trigger opptyCreationonConvert on Lead (after update) {     
    List<Opportunity> o= new List<Opportunity>();    

  for (Lead convertedLead : Trigger.new) {           

      if (convertedLead.IsConverted && convertedLead.ConvertedOpportunityId==null)            {         

              o.add (new Opportunity(                   

    Name = convertedLead.Company,                 

      CloseDate = date.today()+90,           

            AccountId = convertedLead.ConvertedAccountId,     

                  StageName = '1 - Qualification'));                        

          }     }  

  if (!o.isEmpty()) { 

       insert o;   

  }     }

Shashikant SharmaShashikant Sharma

There is no reason this trigger is creating two opportunities . Please verify

1)do you have nay other trigger on Lead which also creates a opportunity ?

2)You have any trigger on opportunity insert which updated Lead? Pleaselet me know if you have any trigger on opportunity insert.

 

These can be the reason

 

Nagesh ENagesh E

no other trigger on opportunity  is creating new record. 

 

when I am converting Lead if the Check box "Do not create Opportunity on convert" is checked then 

trigger is firing and Creating  opportunity manually i wrote this trigger, this is firing twice. 

when I go and change the Lead Convert Settings : 
Enforce Validation and Triggers from Lead Convert : from true to false (if I uncheck ) it is firing only once.