You need to sign in to do that
Don't have an account?
very urgent issue.....
HI,
I am trying to convert a lead to Account , Opportunity , Contact .
But i am getting Error as :
ConvertLead failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, System.DmlException: Update failed. First exception on row 0 with id 00QK0000002q7ZnMAI; first error: CANNOT_UPDATE_CONVERTED_LEAD, cannot reference converted lead: []
trigger LeadConvert on Lead (after insert)
{
for(Lead myLead: Trigger.new)
{
Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(myLead.id);
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());
}
}
Well it seems like you are trying to convert a already Converted lead. Put a check like this
Thank u
i updated my trigger as
trigger LeadConvert on Lead (after insert)
{
for(Lead myLead: Trigger.new)
{
if (myLead.isconverted==false){
Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(myLead.id);
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());
}
}
}
but i am facing same problem .
I guess, the problem is with the below line of code
But since you are not updating the row, i'm still not sure how you got it.. But, can you make a workaround for dat statement?