-
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
Personalizing Shopping Experiences with Salesforce Marketing Cloud and AI-Based Automation
In a world driven by convenience, speed, and relevance, personalization is no longer a “nice-to-have” — it’s a must. Today’s shoppers expect tailored experiences that…
Boost your Business Growth with Salesforce Easy
In this competitive edge, we are continuously advancing in technologies and seeking solutions to grow our business to get ahead in the corporate world. Various…
Salesforce Automation with Process Builder
Following our previous article on automation tools, this article covers automation using the Process Builder tool in more detail. Process Builder is the newest Salesforce automation tool…
Popular Salesforce Videos
TOP 20 Salesforce Integration Interview Questions and Answers 2019 | Salesforce Integration
In this video, Wisdom Jobs and Tutorials explains the 20 most popular questions asked during Salesforce Integration interviews. These questions cover topics like what web…
After Triggers | Trigger in Salesforce - Part 2
In this video, we are going to look into - After Trigger with Example, Our Scenario is - For After Insert Whenever my account record…
Generative AI: What Are Its Benefits For Businesses?
Imagine a world where computers can help businesses come up with creative ideas, solve tricky problems, and even predict what customers might want next. That's…