Toggle Side Panel

  • Home
  • Articles
    • All Articles
    • Blogs
    • Videos
    • Infographics
  • Consultants
    • Salesforce Product Expertise
      • Top Salesforce ConsultantsTop Salesforce Consultants
      • Marketing Cloud ConsultantsMarketing Cloud Consultants
      • Service Cloud ConsultantsService Cloud Consultants
      • Experience Cloud ConsultantsExperience Cloud Consultants
      • Analytics Cloud ConsultantsAnalytics Cloud Consultants
    • Salesforce Industry Expertise
      • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
      • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
      • Health Cloud ConsultantsHealth Cloud Consultants
      • Commerce Cloud ConsultantsCommerce Cloud Consultants
      • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
    • Salesforce Experts by Location
      • USATop Salesforce Consultants in USA
      • IndiaTop Salesforce Consultants in India
      • AustraliaTop Salesforce Consultants in Australia
      • United KingdomTop Salesforce Consultants in UK
      • CanadaTop Salesforce Consultants in Canada
  • Webinars
  • Marketplace
  • Advertise With Us
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Home
    • Articles
      • All Articles
      • Blogs
      • Videos
      • Infographics
    • Consultants
      • Salesforce Product Expertise
        • Top Salesforce ConsultantsTop Salesforce Consultants
        • Marketing Cloud ConsultantsMarketing Cloud Consultants
        • Service Cloud ConsultantsService Cloud Consultants
        • Experience Cloud ConsultantsExperience Cloud Consultants
        • Analytics Cloud ConsultantsAnalytics Cloud Consultants
      • Salesforce Industry Expertise
        • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
        • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
        • Health Cloud ConsultantsHealth Cloud Consultants
        • Commerce Cloud ConsultantsCommerce Cloud Consultants
        • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
      • Salesforce Experts by Location
        • USATop Salesforce Consultants in USA
        • IndiaTop Salesforce Consultants in India
        • AustraliaTop Salesforce Consultants in Australia
        • United KingdomTop Salesforce Consultants in UK
        • CanadaTop Salesforce Consultants in Canada
    • Webinars
    • Marketplace
    • Advertise With Us
    • Contact Us
    • Discussions
    Close search

    Activity › Forums › Salesforce® Discussions › Salesforce Trigger to convert leads into accounts and contacts and add task to it

    Tagged: Account Detail, After Insert, After Update, Contact List in Salesforce, Contact Record, Database Query, Lead Records, Salesforce Database, Salesforce Records, Salesforce Trigger, Salesforce Trigger Condition, Task

    • Salesforce® Discussions

      Salesforce Trigger to convert leads into accounts and contacts and add task to it

      Posted by ANISH KUMAR on January 13, 2018 at 1:30 PM

      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());

      }
      }
      }

       

      Shubham replied 8 years, 2 months ago 2 Members · 1 Reply
      • Account Detail
      • After Insert
      • After Update
      • Contact List in Salesforce
      • Contact Record
      • Database Query
      • Lead Records
      • Salesforce Database
      • Salesforce Records
      • Salesforce Trigger
      • Salesforce Trigger Condition
      • Task
    • 1 Reply
    • Shubham

      Member
      January 16, 2018 at 2:29 PM

      Can you please elaborate more what is your query ?

    Log In to reply.

    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me

    application solution

    Popular Salesforce Blogs

    Apex Triggers in Salesforce Here’s What you Need to Know

    Apex Triggers in Salesforce | Here’s What you Need to Know

    Blog in Salesforce

    What are Apex triggers? Apex triggers permit custom moves to be done before or after data manipulation language (DML) activities arise in Salesforce, such as…

    Apex Triggers, API, Before Insert, Before Trigger, Bulkified Trigger
    Nikhil Kumar Feb 8, 2023
    1,862  Views
    Custom Range of Years for Standard Date Field in Salesforce

    Custom "Range of Years" for "Standard Date Field" in Salesforce

    Blog in Coding and Scripting, Salesforce customization

    Have you ever noticed that the standard date field shows year Range to only up to 7 years? What if we want that Range to…

    Date Field, Range of Years, Salesforce Code, Salesforce Customization, Salesforce Standard Fields
    Manpreet Apr 26, 2018
    5,946  Views

    Salesforce Marketing Cloud on Core for Nonprofits

    Blog in Salesforce Cloud Platform

    Salesforce Marketing Cloud Growth and Advanced Editions are powerful tools that help you and your nonprofit manage your campaigns, analyze your results, and connect with…

    Advanced Edition, Ai, Campaign Brief, campaign flows, Campaign object
    DB Nov 11, 2025
    114  Views

    Popular Salesforce Videos

    How to use Cauzali in Salesforce Service/sales cloud and all of Salesforce industry clouds. Add functionality to your users with Cauzali

    How to use Cauzali in Salesforce Service/sales cloud and all of Salesforce industry clouds. Add functionality to your users with Cauzali

    Video in Coding and Scripting, Salesforce Cloud Platform

    With a maximum price of $6.000 a year for your org. You and your colleague can make all the solutions you want including Community solutions.…

    salesforce, Salesforce Cloud Platform, Salesforce Industry, Salesforce Video, Sales Cloud
    Tom Bo May 14, 2020
    1,590  Views
    Welcome to the New World of Data Collection | Salesforce

    Welcome to the New World of Data Collection | Salesforce

    Video in Others

    Secure data collection built for your needs. With FormAssembly, your organization can streamline outdated processes and power important business initiatives. Click the link below to…

    Salesforce Training, Salesforce Tutorial, Salesforce Administration, Salesforce Developer, Salesforce Integration
    S2 Apr 1, 2022
    2,105  Views
    What are Salesforce Editions and Pricing in Details?

    What are Salesforce Editions and Pricing in Details?

    Video in Salesforce Admin

    Salesforce Editions and Pricing - Salesforce are providing four types of licenses Essentials, Professionals, Enterprise and Unlimited. Watch the video and if you have any…

    Salesforce Training, Salesforce Administration, Salesforce CRM, Salesforce Editions, Developer Edition
    CRS Apr 6, 2022
    3,265  Views
    Footer Forcetalks logo

    support@forcetalks.com

    • twitterx

    Quick Links

    Advertise with Us

    Salesforce® Articles

    Dreamforce 2023

    Top Salesforce® Bloggers 2023

    Top Salesforce Consultants

    Get Listed

    Company

    Contact Us

    About Us

    Privacy Policy

    Terms & Conditions

    InsightHub

    Salesforce Blogs

    Salesforce Videos

    Salesforce Groups

    Salesforce Jobs

    © 2026 - Forcetalks ● All Rights Reserved

    Salesforce® is a trademark of Salesforce® Inc. No claim is made to the exclusive right to use “Salesforce”. Any services offered within the Forcetalks website/app are not sponsored or endorsed by Salesforce®.

    Try AuditMyCRM - It is a Salesforce CRM Audit tool which comprehensively scans your Salesforce org and gives you the list of errors or warnings you need to take care of.
    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.