Skip to main content
1 of 3
sfdcfox
  • 501.7k
  • 21
  • 473
  • 828

convertStatus is null. My guess is that you have more than one valid converted status. You didn't get the appropriate error because you used a try-catch block to catch the QueryException without actually reporting an error. Consider changing your code from this:

try{
    convertStatus = [SELECT Id, MasterLabel 
                            FROM LeadStatus 
                            WHERE IsConverted=true and MasterLabel='Converted' and Id != null]; 
}catch(System.QueryException e){
    System.debug('caught ya!');
}

To this:

convertStatus = [SELECT Id, MasterLabel 
                            FROM LeadStatus 
                            WHERE IsConverted=true and MasterLabel='Converted' LIMIT 1]; 
sfdcfox
  • 501.7k
  • 21
  • 473
  • 828