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
Siddharth PrakashSiddharth Prakash 

Open opportunity edit page after lead conversion

Hi,

I need to open the opportunity edit page after lead conversion in order to enter opportunity classification custom fields. Please advise how can we implement it using apex.

Regards
Siddharth
Pankaj_GanwaniPankaj_Ganwani
Hi,

You can use below mentioned code to achieve this functionality:
 
public class ConvertThelead
{
     public ConvertThelead()
     {
     
     }
     
     public pageReference LeadToConvert()
    {
           Database.LeadConvert lc = new Database.LeadConvert();
            lc.setLeadId('00Q28000000xlKl');
            
            LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
            lc.setConvertedStatus(convertStatus.MasterLabel);
            Database.LeadConvertResult lcr = Database.convertLead(lc);
            return new pageReference('/'+lcr.getOpportunityId()+'/e');
    }
}