LeadConvert

The convertLead Database method converts a lead into an account and contact, as well as (optionally) an opportunity. TheconvertLead takes an instance of the Database.LeadConvert class as a parameter. 

Example

This example shows how to use the Database.convertLead method to convert a lead. It inserts a new lead, creates aLeadConvert object, sets its status to converted, then passes it to the Database.convertLead method. Finally, it verifies that the conversion was successful.

Lead myLead = new Lead(LastName = 'Fry', Company='Fry And Sons');
insert myLead;

Database.LeadConvert lc = new Database.LeadConvert();
lc.setLeadId(myLead.id);

LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);

Database.LeadConvertResult lcr = Database.convertLead(lc);
system.debug('LeadConvertedResult=='+lcr);



Related Posts:

  • What is Cloud cloud Computing provides us a means by which we can access the applications as utilities, over the Internet. It allows us to create, configure, … Read More
  • Query in Custom Button in Salesforce {!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")}{!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")} var recordtypeResultIDD = sforce.connection.query("Selec… Read More
  • Parent to Child SOQL Account to Contact -Parent to Child SOQL Select id, Name,(Select Name,Birthdate,Email from Contacts) from Account where id=… Read More
  • Child to Parent SOQL Contact to Account (Child to Parent) SOQL Contact Parent Account, Account Parent Position Select Name, Account.Name, Account.Industry, Accoun… Read More
  • Licence in salesforce A user license determines the baseline of features that the user can access. Every user must have exactly one user license. Salesforce offers these… Read More

0 comments:

Post a Comment