-
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
Why ISVs Must Strive Harder To Be On AppExchange?
Are you on Salesforce AppExchange? How many apps do you have on Salesforce AppExchange? If you are an ISV then you must be pretty aware…
Difference Between Salesforce Classic And Salesforce Lightning – Part 2
In the first blog of the Salesforce Lightning Migration series, we discussed the Lightning Platform and the Lightning App Builder in detail. Now, it’s time…
Salesforce Community Cloud: Use Cases
Community Cloud, as the name suggests, is a Salesforce platform that gives companies the tools to create branded online communities. Through these communities, companies can…
Popular Salesforce Videos
Process Builder In Salesforce | Tutorial Video
Do you want to create a record for any object from a workflow? Do you want to call your Apex class from a workflow? Do…
How to Get A Part Time Salesforce Job
In this video, Brad discusses different techniques to convince a potential employer to offer you a part-time Salesforce position. This job option allows for additional…
How you can Increase your Salesforce Efficiency and Productivity
In this video, Brad discusses how to increase your workplace efficiency and productivity using various Google Chrome extensions and techniques. As always, we have linked…