-
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
Introducing Salesforce Starter For Indian Business
In today's competitive landscape, micro, small, and medium-sized enterprises (MSMEs) in India strive to stand out, enhance customer experiences, and drive revenue. To address these…
How to Import Your Salesforce Metadata into AbstraLinx in 2024?
In the dynamic landscape of data management, the need for efficient and user-friendly tools has never been more critical. This article unveils AbstraLinx, a specialized…
Top New Features in Spring’24 Release: Salesforce Platform in Lightning
To all the Salesforce enthusiasts, we’re excited to share the latest enhancements, features, and modifications rolled out on the Salesforce Lightning Platform. The top new Salesforce features…
Popular Salesforce Videos
Meet the Salesforce Singapore Small Business Relief Grants Recipients
Small businesses are the heart of our community and the driver of the economy. Salesforce and Singapore Business Federation are pleased to announce the successful…
TrailheaDX '18 Opening Keynote - Part 5: Make Apps Smarter
Related Videos: Salesforce TrailheaDX ’18 Opening Keynote – Part 1: Create Connected Customer Experiences TrailheaDX ’18 Opening Keynote – Part 2: Salesforce Platform TrailheaDX ’18…
Salesforce Tutorial For Beginners | Introduction To Salesforce | Salesforce Training
This video on Salesforce training will help you understand the easy and best tool for CRM and Branding. You will learn how to customize the…