How to convert Automatically lead to Account,contact,Opportunity Trigger.
trigger LeadHandler on Lead (after insert)
{
list<Account> listacc=new list<Account>();
list<contact> listcon=new list<contact>();
list<Opportunity> listopp=new list<Opportunity>();
for(Lead l:trigger.new)
{
Account acc=new Account();
acc.name=l.Company;
acc.phone=l.phone;
listacc.add(acc);
Contact con=new Contact();
con.lastName=l.lastName;
listcon.add(con);
Opportunity opp=new Opportunity();
opp.Amount=l.AnnualRevenue;
opp.Name=l.FirstName;
opp.CloseDate=system.today();
opp.stageName='Closed Won';
opp.Name=l.FirstName;
listopp.add(opp);
}
insert listacc;
insert listcon;
insert listopp;
}
No comments:
Post a Comment