You need to sign in to do that
Don't have an account?
Harry Austin
Hello, I want to create account and contact through the lead creation.
But, My code is executing well without errors. Please check the below code and let me know your comments,
Class Code------
public class LeadAccContact {
@future
public static void LeadAcc(set<Id> lIds)
{
list <lead> l=[select id,FirstName,LastName,phone,email from lead where id in :lIds];
list<account> a=new list<account>();
list<contact> c=new list<contact>();
for(lead tld:l)
{
account k=new account(name=tld.Company,phone=tld.phone);
a.add(k);
contact j=new contact(Lastname=tld.Lastname+' '+ tld.FirstName);
c.add(j);
}
Insert a;
Insert c;
}
}
----Trigger---
trigger leadACC_CON on Lead(after insert) {
LeadAccContact.LeadAcc(Trigger.newMap.keySet());
}
Class Code------
public class LeadAccContact {
@future
public static void LeadAcc(set<Id> lIds)
{
list <lead> l=[select id,FirstName,LastName,phone,email from lead where id in :lIds];
list<account> a=new list<account>();
list<contact> c=new list<contact>();
for(lead tld:l)
{
account k=new account(name=tld.Company,phone=tld.phone);
a.add(k);
contact j=new contact(Lastname=tld.Lastname+' '+ tld.FirstName);
c.add(j);
}
Insert a;
Insert c;
}
}
----Trigger---
trigger leadACC_CON on Lead(after insert) {
LeadAccContact.LeadAcc(Trigger.newMap.keySet());
}