-
Salesforce Trigger to convert leads into accounts and contacts and add task to it
Salesforce Trigger to convert leads into accounts and contacts and add task to it
trigger LeadConvert on Lead (after insert,after update) {
//Bulkified
for (Lead lead : Trigger.new) {
if (lead.isConverted == false) //to prevent recursion{
Database.LeadConvert lc = new Database.LeadConvert();
lc.setLeadId(lead.Id);String oppName = lead.Name;
lc.setOpportunityName(oppName);LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);Database.LeadConvertResult lcr = Database.convertLead(lc);
//System.assert(lcr.isSuccess());}
}
}
Log In to reply.
Popular Salesforce Blogs
Don't Miss to Check Out The Top Salesforce Trends In 2022
Salesforce is taking its strength in cloud computing to a new level. It gained market share by making an easy to use and affordable software…
Tips to Find the Right Salesforce Managed Services Provider for Small Business
Choosing the right Salesforce Managed Services provider can be tough for small businesses. You need a partner who understands your needs, fits your budget, and helps you grow.…
Popular Salesforce Videos
Automated Lead Conversion: Triggering Success When a Lead is Born!
Benefits of Trigger-Based Conversion Instantaneous Response to New Leads Improved Lead Nurturing and Engagement Streamlined Sales Process for Maximum Efficiency Data-Driven Insights for Continuous Improvement…
Lightning Flow – Release Readiness LIVE, Summer '20 | Salesforce
Watch this amazing video & join the Product Managers to see how you can build flows and processes more efficiently with enhancements to Flow Builder,…
Modern App Development On Salesforce - Apex Testing
In this series, you will explore Modern App Development on the Salesforce platform, including Heroku. The live hands-on sessions will take you through the journey…