You need to sign in to do that
Don't have an account?
RECORD_IN_USE_BY_WORKFLOW, Unable to convert lead that is in use by workflow: []
Hi,
In my Apex class i am converting leads. When i test my code through UI it is working fine but when i run my test class it get failed and shows this error:
22:21:47.413 (413465000)|FATAL_ERROR|leadconvert.BulkLeadConvert.LeadInUseByWorkflowException: 00Qi0000003QfGrEAK
(System Code)
22:21:47.413 (413480000)|FATAL_ERROR|leadconvert.BulkLeadConvert.LeadInUseByWorkflowException: 00Qi0000003QfGrEAK
(System Code) 22:21:47.414 (414323000)|DML_END|[237] 22:21:47.414 (414406000)|EXCEPTION_THROWN|[237]|System.DmlException: ConvertLead failed. First exception on row 0; first error: RECORD_IN_USE_BY_WORKFLOW, Unable to convert lead that is in use by workflow: []
I am just passing list of leads as parameter into convertlead() in Apex class :
List<Database.LeadConvertResult> lcr = Database.convertLead(listOfLeadConvert);
My test class
@isTest(SeeAllData=true) public class Test_CVFC_massConvertwithInputs { public static testmethod void Test_CVFC_massConvertwithInputs(){ Account a = new Account (); a.Name = 'LeadCompany'; insert a; Opportunity o = new Opportunity(); o.AccountId = a.Id; o.Name = 'LeadCompany'; O.StageName = 'Prospecting'; O.CloseDate = date.today(); insert o; Contact c = new Contact(); c.AccountId = a.id; c.FirstName = 'LeadFirstname'; c.LastName = 'Leadlastname'; c.MailingStreet = 'LeadStreet'; c.MailingCity = 'LeadCity'; c.MailingState = 'LeadState'; c.MailingPostalCode = '09877'; insert c; Lead l = new Lead(); //l.Name = 'LeadName'; l.Company = 'LeadCompany'; l.IsUnreadByOwner__c = true; l.Description = 'leadDescription'; //l.Status = 'Closed - Converted'; l.FirstName = 'LeadFirstname'; l.LastName ='Leadlastname'; l.Street = 'LeadStreet'; l.City = 'LeadCity'; l.State = 'LeadState'; l.PostalCode = '09877'; insert l; List<Lead> leadLst = new List<Lead>(); leadLst = [SELECT FirstName, LastName, Street, City, State, PostalCode from Lead where id =: l.Id ]; /*Database.LeadConvert lc = new Database.LeadConvert(); lc.setLeadId(l.Id); LeadStatus convertStatus = [Select Id, MasterLabel from LeadStatus where IsConverted=true limit 1]; lc.setConvertedStatus(convertStatus.MasterLabel);*/ PageReference pageRef = Page.massConvertWithInputs; Test.setCurrentPage(pageRef); pageRef.getParameters().put('toconvertLeadIds', l.id); ApexPages.StandardController sc = new ApexPages.standardController(l); CVFC_massConvertwithInputs cmc = new CVFC_massConvertwithInputs(sc); system.debug('Wrapper list size '+cmc.wrapperList.size()); for(Integer i = 0; i < cmc.wrapperList.size(); i++){ System.debug('Values in Wrapper list ' + cmc.wrapperList[i]); } //cmc.leadIds = leadLst; cmc.convert(); } }
is there any thing i am missing out please guide me.
Thanks
Anu
Hi,
The error message is pretty self explanatory.
From the help: You can’t convert a lead that’s associated with an active approval process or has pending workflow actions.
Reference: http://login.salesforce.com/help/doc/en/leads_notes.htm
-Hengky-