-
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
4 New Salesforce Einstein Features – What it means for Service Cloud users
Salesforce Einstein Key Features – Salesforce’s recent announcement of Einstein Artificial Intelligence capabilities have quickly made headlines and for all the right reasons. With the…
How To Create Custom Settings And Custom Objects | Salesforce Developer Guide
Custom Settings Custom settings are similar to custom objects which allow us to customize org data. Following are the steps to create Custom settings:- 1.…
What are Auto-Launched Flows? | All You Need to Know
What are Auto-launched Flows? A certain event, such as the creation or updating of a record or the receiving of a platform event, can automatically…
Popular Salesforce Videos
What are Salesforce Developer Edition?
Salesforce Developer Account is actually a free of cost account. If you wanted to explore and if you wanted to do the configuration practices or…
What are APEX Environments? | Learn Salesforce Development
In this video, Shrey explained the Apex Environments. He covered answers for the following questions while explaining: What are the APEX Environments? Different types of…
Salsa Engage Reports and Dashboards: Mission focused Data Visualization
A Salsa Engage integration with Salesforce gives you comprehensive reports and high-performance dashboards and helps you to optimize your fundraising goals and retain supporters. Get…