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 › How to create a opportunity converted from lead in test class?

    Tagged: Account, Contact, Database, Lead, Lead Convert, Salesforce Opportunity, Test Class

    • Salesforce® Discussions

      How to create a opportunity converted from lead in test class?

      Posted by Ravi on April 30, 2016 at 6:01 PM

      How to create a opportunity converted from lead in test class?

      Surbhi replied 9 years, 6 months ago 2 Members · 1 Reply
      • Account
      • Contact
      • Database
      • Lead
      • Lead Convert
      • Salesforce Opportunity
      • Test Class
    • 1 Reply
    • Surbhi

      Member
      May 26, 2016 at 6:29 AM

      Hi Ravi,

      Please find below the code for creating lead and converting it to account, contact and opportunity in test class.

      Lead lead = new Lead();
      lead.FirstName='James';
      lead.LastName='Dane';
      lead.Company='Test Company';
      lead.LeadSource='GetTimely Online';
      insert lead;

      Database.LeadConvert lc = new database.LeadConvert();
      lc.setLeadId(lead.Id);

      Database.LeadConvertResult lcr = Database.convertLead(lc);

      Thanks

       

    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

    What is the use of Salesforce Audit Fields and How to Enable These fields for your salesforce Org?

    What is the use of Salesforce Audit Fields and How to Enable These fields for your Salesforce Org?

    Blog in Salesforce Implementation

    So, first discuss how to enable "Salesforce Audit Fields” in our Org. Here are the following steps: First, click on “Setup” in Salesforce Org. Now,…

    CampaignMember, CaseComment, Content Version, Contracts in Salesforce, FeedComment
    Rajan Mar 16, 2018
    7,610  Views

    Make Your CRM Future-Ready: Migrate from Salesforce Classic to Lightning

    Blog in Salesforce

    Classic and Lightning are the two common versions of the Salesforce CRM UI. The newer Salesforce Lightning version gives clients a more natural and easy-to-use…

    App Builder, Assurance Level, Automation, Campaign Strategies, Charts
    Damco Aug 9, 2023
    1,933  Views
    Send Salesforce Campaign Members to MailChimp for Email Marketing

    Send Salesforce Campaign Members to MailChimp for Email Marketing

    Blog in Salesforce integration

    After successfull installation and configuration of MailChimp for Salesforce app, Please follow the steps to add Campaign Members to the MailChimp List directly from the…

    Configure Mailchimp for Salesforce, Email in Salesforce, Email Marketing, Email Service, Email Services in Salesforce
    PRANAV May 31, 2018
    5,039  Views

    Popular Salesforce Videos

    Salesforce Lightning Development Tutorial - Lightning Components in Visualforce

    Salesforce Lightning Development Tutorial - Lightning Components in Visualforce

    Video in Others

    Salesforce Lightning Custom Component Development Tutorial for Beginners Learn how to embed lightning components in a Visualforce page. 3 Steps Add apex:includeLightning tag in your…

    Salesforce Tutorial for Beginners, Salesforce Visualforce Page, Salesforce Lightning App, Salesforce Lightning Component, Javascript
    Neha Yadav Dec 9, 2019
    8,510  Views
    SQL Row_Number - Salesforce Marketing Cloud Functions in 5 minutes

    SQL Row_Number - Salesforce Marketing Cloud Functions in 5 minutes

    Video in Salesforce Training

    Cameron Robert shows how to use the Row Number (Over Partition By) SQL function in Salesforce Marketing Cloud. The SQL Row Number function can be…

    Salesforce Training, Salesforce Tutorial, salesforce, Marketing Automation, Salesforce Marketing Cloud
    Cameron Jul 19, 2022
    3,243  Views
    How Admins Can Improve Salesforce Data Quality

    How Admins Can Improve Salesforce Data Quality

    Video in Data, Salesforce Training

    Learn how to diagnose the accuracy of your data and build a plan to maintain and enhance its’ quality using Salesforce tools. Follow along to…

    Salesforce Training, Salesforce Tutorial, Salesforce Tools, Data Quality, Admins
    Prafull Jun 10, 2022
    2,193  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

    © 2025 - 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.