-
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
Learn All About the Report Types in Salesforce
A report is a list of records that meet certain criteria. These records are visualized as a table that can be filtered or grouped based on any field.…
How to Freeze and Deactivate the User Account | Salesforce Developer Guide
Introduction Hello all, here we are going to learn about freezing the users accounts and deactivating the user account. Sometimes we need to delete some…
5 Top Benefits of Using Salesforce CRM for Banks in 2023
A CEO of a well-known investment bank once remarked proper use of technology is the cornerstone of success of a modern financial organization, and rightly…
Popular Salesforce Videos
2020 Salesforce App Builder Certification Questions Explained
The Salesforce Platform App Builder credential is designed for individuals who would like to demonstrate their skills and knowledge in designing, building, and deploying custom…
Salesforce Platform Quick Tip: How to Solve Issues with Error Code Validation
Want to troubleshoot your validation errors faster? Trailblazer and Senior Salesforce Administrator, Monica Doyle walks us through how to add error codes to a validation…
Create Custom App in Salesforce | Salesforce Custom App | Salesforce Tutorial
Watch this amazing video to learn how to create a custom app in Salesforce. Salesforce is a cloud-based platform that has transformed how companies have…