Skip to main content
replaced http://salesforce.stackexchange.com/ with https://salesforce.stackexchange.com/
Source Link

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]; 

In general, if you're not prepared to handle an exception, do not use a try-catch block. See this question and answerthis question and answer for when using try-catch is okay, and when it's not.

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]; 

In general, if you're not prepared to handle an exception, do not use a try-catch block. See this question and answer for when using try-catch is okay, and when it's not.

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]; 

In general, if you're not prepared to handle an exception, do not use a try-catch block. See this question and answer for when using try-catch is okay, and when it's not.

added 226 characters in body
Source Link
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]; 

In general, if you're not prepared to handle an exception, do not use a try-catch block. See this question and answer for when using try-catch is okay, and when it's not.

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]; 

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]; 

In general, if you're not prepared to handle an exception, do not use a try-catch block. See this question and answer for when using try-catch is okay, and when it's not.

Source Link
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];