-
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 I Failed to Upsell to a Customer Because I Recommended Salesforce Professional Edition
I am sharing this story because of how important it is for consultants like myself to not make hasty decisions when making recommendations on Salesforce…
How Can We Add Global Actions to Salesforce1?
Hello guys, Today we see that how we can add global action in Salesforce1. But first, let’s see brief definition of that what is global…
Apex Integration in Salesforce - The Developer Guide
This article closes the arrangement, Learning Salesforce Integration, which subtleties different joining choices with Salesforce. It covers utilizing Apex for building incorporations, which turns into…
Popular Salesforce Videos
Subscribe to Dashboards and Reports (Salesforce Lightning Experience)
By subscribing to a dashboard or report, you can have it refreshed and waiting in your inbox before the weekly sales meeting, or whenever you…
Good Time To Buy Salesforce Stock? CRM Stock Analysis
CRM stock price is currently all over after reporting its SALESFORCE earnings report. I am considering if I should buy CRM Stock. This is a…
Salesforce DX Keynote: Continuous Development on the Lightning Platform
Calling all developers for a deep dive into how everyone, whether you click or code, can build on the Lightning Platform! Join us and learn…