0

I am trying to convert a Lead in a Test Class but i'm facing the exception above. I searched about this error but it's didn't helpfull. I try to follow these steps to search for a solution: https://help.salesforce.com/s/articleView?id=000385353&type=1

But i don't have any active workflow rules, time-based workflows, paused flow interview or approval proccess. And to test the last item, i try to inactivate all Account, Opportunity and Leads, validation rules from my org to verify if could be one of them

There is the part of my code that should convert the Lead

Test.startTest();

LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted = true LIMIT 1];
Database.LeadConvert leadToConvert = new Database.LeadConvert();

leadToConvert.setLeadId(leadToInsert.Id);
leadToConvert.setDoNotCreateOpportunity(true);
leadToConvert.setConvertedStatus(ConvertStatus.MasterLabel);

Database.LeadConvertResult leadAlreadyConverted = Database.convertLead(leadToConvert);
System.assert(leadAlreadyConverted.isSuccess());
if(leadAlreadyConverted.isSuccess()){
    leadToConvert.setOpportunityId(opportunityToInsert.Id);
}

Test.stopTest();
4
  • Can you check if any trigger handler is calling a flow interview and scheduling an action in future for the lead? Also, please check if there is any active approval process as it is mentioned in the article. Aug 29, 2023 at 4:22
  • I searched in my VS Code and don't have any call to a flow interview or scheduling an action. Also i already searched for approval process and i don't find anything Aug 29, 2023 at 11:37
  • Can you check the log generated by this test method? It will surely highlight any workflow in action. Aug 30, 2023 at 4:00
  • We resolved the problem, i'll update the question with the solution. Thanks for your help, Manuj! Aug 30, 2023 at 20:13

1 Answer 1

0

SOLUTION: While we are searching for a solution, we resolve to inactivate each Flow from Lead, Opportunity and Account org. We found a flow that was executed on Create event, and this flow has an assync path, and that was causing the exception. To solve this problem we used a workaround, we create a Boolean field in Lead to be used as a entry condition in flow only if this field is false and set him as true in the test class.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .