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
Suresh Kumar 34Suresh Kumar 34 

auto create a contact

hi all,

how to create a trigger for creating a contact when account is created.

Thank you,
Suresh kumar
trigger createContactTrigger on Account(after insert){
List<Account> accList =;
List<Contact> conList = List<Contact>();
for(Account acc : accList){
Contact con = new Contact();
con.LastName = acc.Name;;
insert conList;
Amit Chaudhary 8Amit Chaudhary 8
Please try below code. I hope that will help u
trigger AccountTrigger on Account( after insert)
	List<Contact> lstCont = new List<Contact>();
	For(Acount acc: trigger.New)
		Contact cont = new Contact();
		cont.LastName ='Trigger';
		cont.accountId =;

	if(lstCont.size() > 0 )
		insert lstCont;
Please check below blog if you want to learn how to write trigger

Please let us know if above trigger will help u

AMit Chaudhary