You need to sign in to do that
Don't have an account?
convert 2 leads at one time.
Here is the scenario: I have a lead that has a lookup to another lead. I want when the first lead is converted to automatically convert the second lead. I have created a trigger to convert the second lead but I keep getting an error that says: " first error: CANNOT_UPDATE_CONVERTED_LEAD, cannot reference converted lead: [] (System Code)"
Here is my trigger:
trigger owner2LeadConvert on Lead (after update) { for (lead l : trigger.new) { if (l.isconverted == true && l.Owner_2__c != null) { system.debug(logginglevel.info, '*****'); Database.LeadConvert lc = new database.LeadConvert(); lc.setLeadId(l.Owner_2__c); 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()); } } }
I checked the debugs and it is running my trigger and it is when it tries to convert the second lead that it has the error. I have tried about the same thing off of the account and get the exact same error. They are being converted to person accounts if that matters.
I found the issue. There was a workflow rule causing the problem. I am not sure which one yet but out of desperation I disabled all my workflow rules and it started working. Thank you for your help. Sometimes it is not the answer that helps me get the problem fixed but the fact that others were not seeing something obviously wrong with my code got me looking elsewhere for the answer.
All Answers
You can check with before trigger. As after lead convert it cannot be referenced to anywhere.
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
Thanks for your reply, I tried that and get the exact same error on a before trigger.
I found the issue. There was a workflow rule causing the problem. I am not sure which one yet but out of desperation I disabled all my workflow rules and it started working. Thank you for your help. Sometimes it is not the answer that helps me get the problem fixed but the fact that others were not seeing something obviously wrong with my code got me looking elsewhere for the answer.