-
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
Advantages of Integrating Salesforce with Stripe Payment Gateway
As a business owner, you are always looking for ways to maximize your revenue potential and streamline your operations. One of the most effective ways…
Value of Salesforce in Small and Medium Business
Speed is the quintessence of the business world. That is valid for almost every part of our business, yet it's particularly valid for innovation and…
Integration Using Named Credentials | Salesforce Developer Guide
The Following are the Benefits of Using Named Credentials: A Named credential specifies the end URL of the callout and its verification parameters required in…
Popular Salesforce Videos
4 Myths About Salesforce
Salesforce is a platform that helps businesses track the journey their customers take. It can help you effectively track and monitor your marketing and sales…
Salesforce SOAP API integration using Partner WSDL
This video is another one on our Salesforce Integration learning video series, through this video our experts will be going to demonstrate how to use…
Everything New in Salesforce Developer Tools
Your productivity starts and ends with the tools you use. Learn how Salesforce Developer Tooling can help you collaborate more effectively with your whole team.…