• adambreen.ax1546
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies

I have this (working) trigger:

 

trigger convertLeadToImplementationOpportunity on Lead (after update) {
    Set<Lead> leadsToConvert = new Set<Lead>();
    for (Lead lead : Trigger.new){
    	leadsToConvert.add(lead);
    }
    
	for(Lead lead : leadsToConvert){   
		     
	    if(lead.Status == 'Qualified' && !lead.isConverted && lead.isApproved__c == true){	    	
	    		        
	        Database.LeadConvert leadConvert = new database.LeadConvert();
	        LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];

            leadConvert.setConvertedStatus(convertStatus.MasterLabel); // ("Closed - Converted");
            leadConvert.setLeadId(lead.id);

	        Database.LeadConvertResult leadConvertResult = Database.convertLead(leadConvert);
	        System.assert(leadConvertResult.isSuccess());
	    }
    }
}

 

However, I want to specify (or set) each new Opportunity's record type and stage.

 

At the minimum, it's ok to rely on default SF behaviour, but for some reason my new Opportunities are currently created with "Closed - Lost" Stage, which is NOT the first Stage in my stages list.

 

For example purposes, let's say that I want the Opportunity to be created as a Record Type = "New Sale" and have a Stage = "First Presentation".