You need to sign in to do that
Don't have an account?
Nikita Dhamal 4
Error: Compile Error: Illegal assignment from List<Lead> to lead at line 14 column 5
vf code:
<apex:page standardController="Lead" action="{!convertLead}" extensions="ControllerLeadConvertView"> </apex:page>
controller:
public class ControllerLeadConvertView {
public Id leadId;
public String convertedAccountId ;
public ControllerLeadConvertView(ApexPages.StandardController stdController){
leadId = ApexPages.CurrentPage().getParameters().get('id');
}
public PageReference convertLead(){
try
{
lead leadobj=new Lead();
leadobj = [select id,MobilePhone,Company from lead where id =:leadId];
Account a = new Account();
a.Name =leadobj.Company;
insert a;
PageReference newocp= new PageReference('/'+ a.Id);
newocp.setRedirect(true);
return newocp;
}
catch(Exception e)
{
System.Debug('Error - ControllerLeadConvertView.convertLead - Exception [' + e.getMessage() + ']');
return null;
}
}
}
<apex:page standardController="Lead" action="{!convertLead}" extensions="ControllerLeadConvertView"> </apex:page>
controller:
public class ControllerLeadConvertView {
public Id leadId;
public String convertedAccountId ;
public ControllerLeadConvertView(ApexPages.StandardController stdController){
leadId = ApexPages.CurrentPage().getParameters().get('id');
}
public PageReference convertLead(){
try
{
lead leadobj=new Lead();
leadobj = [select id,MobilePhone,Company from lead where id =:leadId];
Account a = new Account();
a.Name =leadobj.Company;
insert a;
PageReference newocp= new PageReference('/'+ a.Id);
newocp.setRedirect(true);
return newocp;
}
catch(Exception e)
{
System.Debug('Error - ControllerLeadConvertView.convertLead - Exception [' + e.getMessage() + ']');
return null;
}
}
}
All Answers
Please let us know if this will help you
At the moment when I am trying to replicate the issue then this code is working fine but this error occurs when we get more than one record and we are trying to store that in a instance of an related object rather than list of that object.
Thanks