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
vodnuravodnura 

Lead to Opportunity Manual Conversion..

After doing some research.. i was rying to convert a Lead to an opportunity using the following code..but keep getting the error mentioned below..can anybody suggest where iam going Wrong...

 

trigger ConvertLead on Lead ( after update) {
for (Lead lead : Trigger.new) {
if (lead.isConverted == false && lead.Approved__c=='YES' )
{

Database.LeadConvert lc = new Database.LeadConvert();
lc.setLeadId(lead.Id);

String oppName = lead.Name;
lc.setOpportunityName(oppName);

LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);

Database.LeadConvertResult lcr = Database.convertLead(lc);
System.assert(lcr.isSuccess());


}
}
}

 

 

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger ConvertLead caused an unexpected exception, contact your administrator: ConvertLead: execution of AfterUpdate caused by: System.DmlException: ConvertLead failed. First exception on row 0; first error: INVALID_STATUS, invalid convertedStatus: Qualified: []: Trigger.ConvertLead: line 15, column 1

 

Appreciate all the help,

Thanks

AJ.

Vinita_SFDCVinita_SFDC

Hello,

 

Please check if the 'Converted' option is checked for the value 'Qualified' in the picklist 'Lead Status'.

 

Setup|Customize|Leads|Field|Lead Status|check for converted checkbox checked for 'Qualified'

vodnuravodnura

Hi Vinita,

 

I did checked the converted Option and its checked.

 

Thanks for looking into this and please let me know if you have more insight tothis..