You need to sign in to do that
Don't have an account?
CeeMo
If statement in method returns opposite value of what is expected
hello
The below code when run is returning the opposite value of what the debug logs show.
I have been unable to find anything to explain why this would happen. Has anyone run into this and been able to resolve the issue? Or is their something that I have done that would cause this.
Thank you for any help for a newbie apex developer.
CeeMo
The below code when run is returning the opposite value of what the debug logs show.
List <Id> leadsToConvert = new List<Id>(); leadsToConvert.add(leadId); List<Id> convertedOpps = new List<Id>(); convertedOpps = ConvertLead.ConvertLeads(leadsToConvert); --> this debug statement shows the Opportunity ID and that the size is 1 System.debug('LeadUtilities.convertTheLead Opp Id = ' + convertedOpps[0] + ' - size = ' + convertedOpps.size()); --> the if statement returns Not Converted even though the size is 1 if (convertedOpps.size() > 0) return 'Converted'; else return 'Not Converted';Here are the debug statements that show the size of the list being returned from convertLeads newOpp (1) and the size of the list in the convertTheLead method (1).
I have been unable to find anything to explain why this would happen. Has anyone run into this and been able to resolve the issue? Or is their something that I have done that would cause this.
Thank you for any help for a newbie apex developer.
CeeMo
-Thanks,
TK
All Answers
-Thanks,
TK
Hi CeeMo,
Please give a try with :- if (convertedOpps.size() == 1) return 'Converted'; else return 'Not Converted';
CeeMo