Sample code:
Lead myLead = new Lead(LastName = 'Foo', Company='Foo Bar');
insert myLead;
Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(myLead.id);
lc.ConvertedStatus = 'Closed - Converted';
Database.LeadConvertResult lcr = Database.convertLead(lc);
System.assert(lcr.isSuccess());
Lead myLead = new Lead(LastName = 'Foo', Company='Foo Bar');
insert myLead;
Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(myLead.id);
lc.ConvertedStatus = 'Closed - Converted';
Database.LeadConvertResult lcr = Database.convertLead(lc);
System.assert(lcr.isSuccess());
Cheers!!!
i have 2 custom fields in lead object, and same custom fields are created in Account, Contact, Opportunity objects when ever the lead is converted that custom fields data is inserted into Account, Contact, Opportunity object fields how can i achieve this using apex code....?
ReplyDeleteUse trigger.
DeleteCheers!
This may be useful
Deletehttp://www.infallibletechie.com/2013/10/validation-rule-and-trigger-is-not.html
Cheers!!!
How can i create 3 more opportunity records of same name ,after this lead conversion process if i implement this using custom button .?
ReplyDeleteAfter the Database.convertLead(lc), create two more opptys with Lead Info for Account, etc.
DeleteCheers!!!
How to fetch Leads with existing company name and make it the child lead of existing Lead
ReplyDeleteI don't think there is no standard way to do this.
Delete