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

    AWOM salesforce apps

    AWOM vs Others – A Comparison of Salesforce’s Opportunity Manager Apps

    Blog in Others, Salesforce

    The old sales rule says: “The opportunity is a deal that you have the possibility to close!” And when your business falls in the large,…

    AWOM, Campaigner Playbook, Opportunity Manager, Pipeline Manager, Salesforce
    Algoworks Oct 13, 2017
    4,683  Views
    What AI Capabilities does Salesforce brings to you?

    What AI Capabilities does Salesforce brings to you?

    Blog in Salesforce Einstein

    AI or Artificial Intelligence is the technology of this era and is giving a new shape and level to customer’s expectations. Now, AI has entered…

    App Cloud Einstein, Career in Salesforce, Community Cloud Einstein, Deployment In Salesforce, IoT Cloud Einstein
    Vikas Sep 28, 2018
    4,002  Views

    What Does a Salesforce Developer Course Include?

    Blog in Salesforce Training

    Since its inception, Salesforce has been the most renowned CRM platform provider in the world. This is due to the robust nature of an ecosystem…

    Apex Programming, Apex Triggers, App Deployment, Aura Components, Certification Guide
    Ray brad Aug 14, 2024
    672  Views

    Popular Salesforce Videos

    How to Build an Email Using Content Builder in Salesforce Marketing Cloud

    How to Build an Email Using Content Builder in Salesforce Marketing Cloud

    Video in Salesforce Training

    Cameron Robert steps through how to build your first email in Salesforce Marketing Cloud using Content Builder by replicating an existing Salesforce email from ReallyGoodEmails.com.…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Marketing Cloud, Salesforce Video
    Cameron Aug 16, 2022
    2,780  Views
    Intro to Salesforce Macros

    Intro to Salesforce Macros

    Video in Others

    Users can run macros to complete repetitive tasks—selecting an email template, sending an email to a customer, updating the case status—all in a single click.…

    Salesforce Sales Cloud, Salesforce Lightning Experience, Sales Cloud Consultant, Lightning App Builder, Automate Business Processes
    Shiv Kumar Sharma Mar 29, 2018
    1,921  Views
    5 Steps to Faster Case Resolution | Salesforce Support

    5 Steps to Faster Case Resolution | Salesforce Support

    Video in Salesforce Stories

    When it comes to filling out a Salesforce case from, the description field and attached files are key to fast routing and resolution. Here are…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Video, Salesforce Learning
    Abhishek Feb 11, 2022
    1,872  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.