You need to sign in to do that
Don't have an account?
Prince Venkat
Lead conversion URL Redirect to Opportunity from Lead
Hi
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();
lConvert.setLeadId(ldRecord.Id);
lConvert.setSendNotificationEmail(true);
lConvert.setDoNotCreateOpportunity(false);
lConvert.setConvertedStatus(lStatus.MasterLabel);
// Add the record to the Collection..
leadsToConvert.Add(lConvert);
}
}
if(! leadsToConvert.isEmpty())
{
Database.LeadConvertResult[] results = Database.convertLead(leadsToConvert);
}
}
}
Thank you
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();
lConvert.setLeadId(ldRecord.Id);
lConvert.setSendNotificationEmail(true);
lConvert.setDoNotCreateOpportunity(false);
lConvert.setConvertedStatus(lStatus.MasterLabel);
// Add the record to the Collection..
leadsToConvert.Add(lConvert);
}
}
if(! leadsToConvert.isEmpty())
{
Database.LeadConvertResult[] results = Database.convertLead(leadsToConvert);
}
}
}
Thank you