-
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
Salesforce Product : Service Cloud
Salesforce Product : Service Cloud The Service Cloud Platform or a customer support platform gives your agents power to deliver service that’s as instant and…
Salesforce Lightning Aura Components Core Concepts
Page & Bundle Visualforce pages (and Visualforce additives, but permits’s set those apart for now) are saved on Salesforce as a single entity, an ApexPage.…
Salesforce Summer'24 Highlights | All You Need to Know
Salesforce’s Summer ‘24 update is here, and its features are like a breath of fresh air. Let’s go over some of the cool features that…
Popular Salesforce Videos
Building a Custom UI with Lightning Web Components | Salesforce Tutorial
Lightning Web Components is a modern JavaScript framework that leverages the web standards breakthroughs over the past few years. Watch this session to understand how…
What is Salesforce? Career Opportunities and Job Roles in Salesforce!
This video deals with the most important aspect of Salesforce. You'll learn the following things from this video:- 1. What is Salesforce? 2. What business…
Deploy Lightning Web Component Files | Salesforce Lightning Tutorial
Learning Objectives After watching this video, you’ll be able to: Configure Lightning web component files for display in an org. Deploy your files to an…