-
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
How to Merge Duplicate Accounts & Contacts in Salesforce Lightning
The differences are stark between the Salesforce Classic and the Salesforce Lightning Experience when it comes to duplicates records. In Salesforce Lightning duplicate alerts are…
How to Integrate HubSpot With Salesforce CRM: Three Options
The goal of every business is to drive sales. However, its success is determined by the synergy of all departments, especially marketing and sales. 52.2%…
Learn All About SOQL in Salesforce
SOQL SOQL is a language that extracts data from the Salesforce database. In Object-Oriented Programming for Admins you found that you can use Data Manipulation…
Popular Salesforce Videos
Case Escalation In Salesforce | Salesforce Development Tutorial
Case Escalation in Salesforce. This video will cover the following points - 1. Case escalation Get a brief introduction about case escalation. 2. Configuration Take…
What is CPQ (in Salesforce)?
This videdo explains Configure Price Quote (CPQ) in Salesforce by dividing this topic into 4 basic points, which are: 1. What is the basic sales…
Spring '21 Release - Time-dependent Action in Salesforce Flows
If you’re familiar with scheduled actions in Process Builder or time-dependent actions in workflow rules, know that scheduled paths on record-triggered flows can accomplish the…