Lead Conversion | Method in Apex Database Class
Chapter Topics
- What Is DML In Salesforce?
- Insert | APEX DML Standalone Statements
- Update | APEX DML Standalone Statements
- Upsert | APEX DML Standalone Statements
- Delete | Apex DML Standalone Statement
- Undelete | Apex DML Standalone Statement
- Merge | APEX DML Standalone Statements
- APEX DML Statements Best Practices
- Database Class in APEX
- Empty Recycle Bin
- Count Query | Method in Apex Database Class
- Lead Conversion | Method in Apex Database Class
- Transaction Control and Rollback
- Database Class Method Result Object
What Is Lead Conversion In Salesforce?
Lead conversion in Salesforce is a process in which a lead record is converted into Accounts, Contacts & Opportunities. This happens when a lead is identified as a qualified Sales prospect.
Lead Conversion Using Apex Coding
There exists a Database class method “convertLead” which is used to convert the lead but other than this method there are various variables and classes used to convert a lead in Apex which is shown below through a Sample code example.
Lead Conversion:public static void main() {
Lead l = [SELECT Name FROM Lead WHERE Name like’ sh % ’LIMIT 1];
Lead l1 = new Lead(LastName = ‘’, CompanyName = ’’);
insert l1;
Database.LeadConvert lc = new Database.LeadConvert();
lc.setLeadId(l.Id);
System.debug(‘ID of record inserted is: ’+l.id);
lc.convertedStatu s = ’Closed Converted’;
lc.ownerId = [SELECT Id FROM User LIMIT 1].Id; // any user id
Database.LeadConvertResult lcr = Database.convertLead(lc);
}
Next Topic
Need more support?
Get a head start with our FREE study notes!
Learn more and get all the answers you need at zero cost. Improve your skills using our detailed notes prepared by industry experts to help you excel.