• Jason Apter
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Convert lead to opportunity= help

Need to automatically convert leads to opportunity- how to add new APEX trigger and

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

       for(Lead convertedLead: Trigger.new){
    if(convertedLead.IsConverted == TRUE && convertedLead.ConvertedOpportunityId == NULL){               
        o.add (new Opportunity(
        Name = convertedLead.Company,
        CloseDate = date.today()+90,
        AccountId = convertedLead.ConvertedAccountId,
        StageName = 'Booked Appointment'));
        }
    }
insert o;

}