-
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
4 Reasons to use AngularJS in Salesforce Visualforce pages
If you ask a web or mobile app developer why they use AngularJS their first reply would be because it’s awesome. And then they would…
How to Capture Replies in Salesforce Using Email Services?
When you are sending Email by using trigger then you have to implement these codes in your trigger - String[] toAddresses = new String[] {lead1.email};…
Back Up Metadata to Secure and Restore Your Customizations | Salesforce Guide
You can protect your organization’s customizations, like customized fields, custom Apex code (Everything you wrote in your console), page layouts, reports, and permission sets, by…
Popular Salesforce Videos
Non-technical But Want to Build Career in Salesforce?
In this video Shrey gave the answer to the following questions: 1. What is the next step after doing Certification in Salesforce Administrator? 2. How…
Is Salesforce A Good Career In 2022?
Wondering whether Salesforce is a good career or not? Still have some doubts about it. Watch this video and join this useful group for Salesforce…
Client Side Search in Lightning Component Salesforce | Lightning Data Table
In this video, I will implement the Client-Side Search functionality in Lightning Data Table in a Custom Lightning Component. Client-Side Search allows users to search…