You need to sign in to do that
Don't have an account?

trigger for lead convert
How to map a custom field in lead to custom fields in both account and opportunity?..how can i write a trigger?
You need to sign in to do that
Don't have an account?
How to map a custom field in lead to custom fields in both account and opportunity?..how can i write a trigger?
You need to create an update Trigger on Lead and need to use ConvertAccountId and ConvertedOpportunityId which would be generated in Lead conversion.Please go through the below link to know more about these fields :-
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_lead.htm
{ Database.LeadConvert[] leadsToConvert = new Database.LeadConvert[];
Database.LeadConvert converter = new Database.LeadConvert();
for(Lead objll : Trigger.New)
{ converter.setLeadId(objll.id);
Account account = new Account(name='Test_Covertlead',NumberOfEmployees = objll.NumberOfEmployees);
insert account;
converter.setAccountId(account.id);
Contact contact = new Contact(firstname='test', lastname='test',accountid=account.id);
insert contact;
converter.setContactId(contact.id);
converter.setConvertedStatus('Qualified - Converted');
converter.setDoNotCreateOpportunity(false);
leadsToConvert.add(converter);}
Database.ConvertLead(leadsToConvert,true);
}
Hi marella,
Please prefer the above code and let me know whether it works for you or not.
Reagrds,
Itswas.