-
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
Get to Know About the B2B Commerce Data Model | Salesforce Help Guide
What Exactly Is B2B Commerce Anyway? Business-to-business (B2B) trade is a world far eliminated from the online business encounters most people are utilized to. B2B…
All You Need to Know About DupeCatcher Salesforce
Duplicate records can be a headache for any Salesforce admin or user. Not only do they clutter up the database and make it difficult to…
The Perks of Getting a Salesforce Certification
Certifications are the way to go these days if one is looking to upskill and grow their career. Degrees are great, but a course certification…
Popular Salesforce Videos
Creating a Salesforce Lightning App in 12 Minutes
Salesforce is the easiest and quickest way to make quality enterprise apps using clicks instead of code.This video attempts to demonstrate just how quick and…
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…
Agile in Salesforce | Agile Salesforce Implementation
Watch this video to learn about Agile Salesforce Implementation When Salesforce met Agile Agile vs Waterfall Introduction to Scrum Scrum Roles Scrum Ceremonies Q&A