-
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
Apex Triggers in Salesforce | Here’s What you Need to Know
What are Apex triggers? Apex triggers permit custom moves to be done before or after data manipulation language (DML) activities arise in Salesforce, such as…
Custom "Range of Years" for "Standard Date Field" in Salesforce
Have you ever noticed that the standard date field shows year Range to only up to 7 years? What if we want that Range to…
Salesforce Marketing Cloud on Core for Nonprofits
Salesforce Marketing Cloud Growth and Advanced Editions are powerful tools that help you and your nonprofit manage your campaigns, analyze your results, and connect with…
Popular Salesforce Videos
How to use Cauzali in Salesforce Service/sales cloud and all of Salesforce industry clouds. Add functionality to your users with Cauzali
With a maximum price of $6.000 a year for your org. You and your colleague can make all the solutions you want including Community solutions.…
Welcome to the New World of Data Collection | Salesforce
Secure data collection built for your needs. With FormAssembly, your organization can streamline outdated processes and power important business initiatives. Click the link below to…
What are Salesforce Editions and Pricing in Details?
Salesforce Editions and Pricing - Salesforce are providing four types of licenses Essentials, Professionals, Enterprise and Unlimited. Watch the video and if you have any…