-
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
Know The Importance of CRM and ERP Integration | Salesforce
At a high level, integrating ERP and CRM empowers your employees to provide fast, informed and more personalized customer service. The reason for ERP and CRM…
Salesforce AI Cloud Roadmap Latest Products 2023
Introduction In today’s fast-paced business world, harnessing the power of artificial intelligence (AI) is becoming increasingly crucial for organizations looking to stay competitive. Salesforce, a…
Salesforce Quotes Best Practices for Quotation Templates
A quotation template is a professional document outlining your products or services, pricing, and terms. It’s more than just a price list; it’s a strategic…
Popular Salesforce Videos
What is Audit Trail in Salesforce?
The Setup Audit Trail feature in Salesforce enables you to closely track changes made to your organization. It records all modifications concerning the administration, customization, security,…
Salesforce Anywhere: Technology Enabling the All-Digital, Work-From-Anywhere World
While companies, governments and organizations are slowly returning to their offices, the COVID-19 pandemic has changed the future of work forever. In fact, nearly 70…
Process Builder - A Tool every Salesforce Developer must know
Salesforce Process Builder - A Tool every Salesforce developer must know. Learn how to master Process builder Salesforce to automate your business processes. In this…