trigger Account_trigger on Account (after insert) {
/** EXAMPLE OF HOW TO -- NOT -- WRITE A BULK TRIGGER **/
// iterate over the list of records being processed in the trigger
List<Opportunity> opp = new List<Opportunity>();
for (Account a : Trigger.new) {
o.Account = a.Id;
o.Name = 'opp 1';
o.CloseDate = Date.today();
o.stageName = 'stage1';
opp.add(o);
}
insert opp;
}
You can just try with the following code snippet.
trigger MyTrigger on Account(after insert){
list<contact> lst = new list<contact>();
for(account a: trigger.new){
contact c = new contact(lastName = a. name,phone = a.phone);
lst.add(c);
}
insert lst;
}
Thanks,
Vijay