-
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

Salesforce Analytics Cloud and Integration Cloud | The Ultimate Guide
Salesforce Analytics Cloud, also known as Einstein Analytics, is a powerful data analytics tool that helps businesses make better decisions by providing them with real-time…

Why Should You Consider Migrating To Salesforce Lightning In 2022?
Salesforce has been in the industry for over two decades and has already carved its niche in the market. The CRM platform has been consistent…

CRM for FinTech: Why Choose Salesforce For Fintech Companies?
Recently German specialists of information technologies published the article “What determines FinTech success?—A taxonomy-based analysis of FinTech success factors”. They provided insights into the potential determinants…
Popular Salesforce Videos
How Do You Select the Right Salesforce Implementation and Transformation Partner?
Looking for Salesforce Certifications while choosing a Salesforce Implementation Partner is no more just enough. In this video Our CEO Jayant Umrani explaining about the…
How Cyntexa Helped Suppliers Of Electronics To Create Their Online Presence? | Salesforce Solutions
Creating an online presence has become one of the most in-demand ways to grow a business. Presenting you a case study showcasing how Cyntexa helped…
Subscribe to Dashboards and Reports (Salesforce Lightning Experience)
By subscribing to a dashboard or report, you can have it refreshed and waiting in your inbox before the weekly sales meeting, or whenever you…