trigger contactopprtupdate on Account (after insert,after update) {
List<contact> conlist = new List<Contact>();
List<opportunity> opptlist = new list<opportunity>();
for(Account Acc:Trigger.new){
contact con = new contact();
opportunity oppt = new opportunity();
con.AccountId=Acc.id;
con.LastName=Acc.Name;
con.FirstName=Acc.Name;
con.Phone = Acc.Phone;
oppt.Name =Acc.Name;
oppt.AccountId=Acc.Id;
oppt.stageName='Closed Won';
oppt.CloseDate=date.Today();
conlist.add(con);
opptlist.add(oppt);
}
insert conlist;
insert opptlist;
}
List<contact> conlist = new List<Contact>();
List<opportunity> opptlist = new list<opportunity>();
for(Account Acc:Trigger.new){
contact con = new contact();
opportunity oppt = new opportunity();
con.AccountId=Acc.id;
con.LastName=Acc.Name;
con.FirstName=Acc.Name;
con.Phone = Acc.Phone;
oppt.Name =Acc.Name;
oppt.AccountId=Acc.Id;
oppt.stageName='Closed Won';
oppt.CloseDate=date.Today();
conlist.add(con);
opptlist.add(oppt);
}
insert conlist;
insert opptlist;
}
No comments:
Post a Comment