You need to sign in to do that
Don't have an account?
sessu
hi
Hi I need to dConvert lead to Account and contact. with the help of ashish I am able to convert in account but Not able to display lead details in contact related list of account. as account is a look up field in contact kindly let me know the code for look up field. My code has error error is Error Error: Compile Error: Illegal assignment from Schema.SObjectField to SOBJECT:Account at line 15 column 5 public class CMyLeadControllerExtension { public ApexPages.StandardController LEAD; public CMyLeadControllerExtension(ApexPages.StandardController stdController) { this.LEAD = stdController; } Lead abc = [select Id,Name, Email, Company,MobilePhone from Lead where id = :apexpages.currentpage().getparameters().get('id')]; public pageReference doCreateAccount(){ Account newacc = new Account(); newacc.Name = abc.Company; insert newacc; Contact newcon = new Contact(); newcon.LastName = abc.Name; newcon.Account= Account.id; ----------------------------------------- newcon.MobilePhone = abc.MobilePhone; newcon.Email = abc.Email; newcon.FirstName = abc.Name; insert newcon; pageReference p = new pageReference('/' + newacc.id); p.setRedirect(true); return p; } }
Hi,
You are getting this error because you are assigning wrong value for accounted on contact. Try the below code as reference:
public class CMyLeadControllerExtension
{
public ApexPages.StandardController LEAD;
public CMyLeadControllerExtension(ApexPages.StandardController stdController)
{
this.LEAD = stdController;
}
Lead abc = [select Id,Name, Email, Company,MobilePhone from Lead where id = :apexpages.currentpage().getparameters().get('id')];
public pageReference doCreateAccount()
{
Account newacc = new Account();
newacc.Name = abc.Company;
insert newacc;
Contact newcon = new Contact();
newcon.LastName = abc.Name;
newcon.Accountid= newacc.id;
newcon.MobilePhone = abc.MobilePhone;
newcon.Email = abc.Email;
newcon.FirstName = abc.Name;
insert newcon;
pageReference p = new pageReference('/' + newacc.id);
p.setRedirect(true);
return p;
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.