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();