-
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
Why Soft Skills Matter More Than Technical Skills When Hiring a Salesforce Developer
Introduction When hiring a Salesforce Developer, most companies focus on technical expertise—proficiency in Apex, Lightning Web Components, and integrations. While technical skills are crucial, they…
Benefits of Salesforce Native Applications for The Growth of Businesses
Salesforce has emerged as a key player, providing a versatile platform for organizations to manage their customer relationships, streamline processes, and drive growth. One of the…
3 Hot Trends Secretly Pointing towards Future of CRM
Customer Relationship Management or CRM is the future of the business and is not going to fed so soon. Starting from small businesses to the…
Popular Salesforce Videos
Salesforce Service Cloud Overview Demo
Service Cloud is a complete service solution built on the Salesforce platform that lets you quickly adapt to change, to deliver trusted service from anywhere.…
Salesforce Multi-factor Authentication/Two-factor Authentication End User Training Video
Watch this video to learn all about Salesforce Multi-factor Authentication/Two-factor Authentication. This is a training video. Watch and learn.
Record Triggered Flows with Real Time Scenarios | Salesforce Tutorial
In this video, you will understand 1. What is Record triggered flow? 2. How and when to use Record triggered flows? 3. Real-time scenarios 4.…