function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Harry AustinHarry 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());
}