function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Øyvind Borgersen 10Øyvind Borgersen 10 

Lead autoconvert not working with web to lead


I have a basic apex leadAutoConvert class which is triggered with a PB. This is working fine when lead is created in Salesforce. However, when I use the web-to-lead it only works when adding lastname and fails when adding email.

The debug log shows no error, and it also shows that it's been creating an opportunity, but no records are created in Salesforce.

Has anyone any similar experience?

Here's the apex class:

Public class AutoConvertLeads
    public static void LeadAssign(List<Id> LeadIds)
        LeadStatus CLeadStatus= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true Limit 1];
        List<Database.LeadConvert> MassLeadconvert = new List<Database.LeadConvert>();
        for(id currentlead: LeadIds){
                Database.LeadConvert Leadconvert = new Database.LeadConvert();
                //Leadconvert.setDoNotCreateOpportunity(TRUE); //Remove this line if you want to create an opportunity from Lead Conversion 
        if (!MassLeadconvert.isEmpty()) {
            List<Database.LeadConvertResult> lcr = Database.convertLead(MassLeadconvert);