+ Start a Discussion
Nagarjun TNagarjun T 

trigger to create contact record from account object

I Need to create contact record automatically when account record is created 
Best Answer chosen by Nagarjun T
Nagarjun TNagarjun T
Trigger accountinsertautomaticallycontactalsoinsert on Account(After Insert,after update)
{
    List<Contact> conlst = new List<Contact>();
    For(Account acc:Trigger.New){
       Contact con = New Contact();
       con.lastname = acc.name;
       con.phone = acc.phone;
       con.accountid=acc.id;
       conlst.add(con);
    }
    insert conlst;