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
Prince VenkatPrince Venkat 

Lead conversion URL Redirect to Opportunity from Lead


Whenever Lead Record is Created and it is converted into opportunity. and then it should immediately change from lead page (00Q) to opportunity page URL (006) (Redirect from lead page to opportunity)

Below is my code.

Any assistance

public class LeadTriggerHandler
    Public static void AfterUpdate(List<Lead> lstLeads)
        LeadStatus lStatus = [Select id, MasterLabel, isConverted
                                                 from LeadStatus
                                                     Where isConverted = true];
        List<Database.LeadConvert> leadsToConvert = new List<Database.LeadConvert>();
        for(Lead ldRecord : lstLeads)
            if(ldRecord.Status == 'Closed - Converted' && ldRecord.IsConverted == false)
                Database.LeadConvert lConvert = new Database.LeadConvert();
                  // Add the record to the Collection..
        if(! leadsToConvert.isEmpty())
            Database.LeadConvertResult[] results =    Database.convertLead(leadsToConvert);

Thank you