Toggle Side Panel

  • Blogs
  • 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
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Blogs
    • 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
    • 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 10 years, 4 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

    Popular Salesforce Blogs

    Features of New Salesforce Lightning

    Learn All About The Features of Newly Launched Salesforce Lightning Platform

    Blog in Lightning

    A Brief of Salesforce Lightning As per the announcement done by Salesforce in its Winter 17 release, Salesforce Lightning is the future CRM of Salesforce,…

    Salesforce Application Development, Salesforce CRM, Salesforce Customization, Salesforce Lightning, Salesforce Lightning Component
    Louis May 19, 2017
    3,729  Views
    Starting your career in Tech? Here are the know-hows of being a Salesforce Developer

    Starting your career in Tech? Here are the know-hows of being a Salesforce Developer

    Blog in Coding and Scripting, Salesforce Certifications

    With increasing technological innovation and the industry shift towards high paced and reliable software solutions, sales force development is one of the hottest trends as…

    Salesforce Certifications, Salesforce Developers, Salesforce Development
    Edifyself Aug 22, 2017
    4,565  Views
    Customize Salesforce Login Page

    How to Customize Salesforce Login Page

    Blog in Salesforce Training, Salesforce Tutorial

    Introduction Here we are going to learn about how to customize the domain name and login page. We will also understand how to change our…

    Change Logo, Custom Domain, Custom or Standard Logo, Deploy New Domain, Domain Name
    Rajat Shende Jun 15, 2021
    14,951  Views

    Popular Salesforce Videos

    My Wild Career Journey: From Lawyer to Salesforce Consultant

    My Wild Career Journey: From Lawyer to Salesforce Consultant

    Video in Salesforce Stories

    People often ask Brainiate what his career journey looked like, and in this video he share with you the key milestones that brought him to…

    Salesforce Training, Salesforce Jobs, Salesforce Consultant, Salesforce Ecosystem, Salesforce Video
    Rupal Kakkar Aug 26, 2021
    2,682  Views
    Driving Gamified Interactions on Salesforce Communities With ScoreNotch | Use-Cases

    Driving Gamified Interactions on Salesforce Communities With ScoreNotch | Use-Cases

    Video in Salesforce Communities

    A Salesforce native and lightning-ready product that makes gamification more dynamic and engaging. It encompasses powerful features that boost community engagement and ROI. Do let…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Video, ROI
    Shubham Mar 25, 2022
    2,125  Views
    5 Tips on How to Run Your Pipeline Engine to Drive Growth | Salesforce on Salesforce

    5 Tips on How to Run Your Pipeline Engine to Drive Growth | Salesforce on Salesforce

    Video in Salesforce Training

    Salesforce’s revenue has been on a firm upward trajectory for years, and every year we see terrific growth. How do we do it? I’ll let…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Revenue, Salesforce Video
    Jogender Jun 17, 2022
    1,754  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®.

    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.