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, 8 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 To Do When Salesforce Apex Heap Size Increases?

    Blog in Salesforce Apex

    Welcome to Salesforce! You've just encountered your first governor limit . The 'Apex heap size too large' error occurs when too much data is being…

    Heap Size, Salesforce Apex Code, Salesforce Apex Page, Salesforce Data, Salesforce Data Management
    Manpreet Feb 19, 2018
    38,583  Views
    Salesforce SMS App

    Salesforce SMS App - Leverage Smart SMS App to Get an Edge Over Your Competitors

    Blog in Others, Salesforce

    A quick, reliable, and universal mode of communication offer much more than convenience to organizations looking to connect with their customers from anywhere and at…

    Automation, Automation through Workflows, Communication Tool, Competitors, CRM systems
    Emily Feb 23, 2021
    3,348  Views
    salesforce lightning component

    Top Salesforce Lightning Components to Improve Functionality

    Blog in Lightning

    In this techie environment, it is the necessity to be with the new generation and meet up the expectation of the business organization. Almost every…

    Apex Test Classes, Application Event, Business Organization, Custom Cache, Event Handlers
    Anjali Apr 21, 2020
    2,557  Views

    Popular Salesforce Videos

    Translation Workbench | Salesforce Tutorial

    Translation Workbench | Salesforce Tutorial

    Video in Others, Salesforce Training

    One of the most common questions new Salesforce admins ask us is how can they translate custom terms when their org is in multiple languges?…

    Salesforce Training, Salesforce Tutorial, Salesforce Admins, Salesforce Video, Salesforce Learning
    Stimulus Consulting Oct 1, 2020
    2,367  Views
    How to Set Up a B2B Marketing Analytics Plus App | Salesforce

    How to Set Up a B2B Marketing Analytics Plus App | Salesforce

    Video in Marketing

    This video shows marketers how they can create a B2B Marketing Analytics Plus app, such as Marketing Campaign Intelligence or Account-Based Marketing. So to get…

    Salesforce Tutorial, salesforce, Salesforce Video, salesforce app, Salesforce Learning
    Nauman Aug 6, 2020
    1,686  Views
    Revenue Generation Opportunities on AppExchange

    Revenue Generation Opportunities on AppExchange

    Video in Others

    If you're an aspiring entrepreneur or a business professional looking to expand your revenue streams, this video is a must-watch! Watch this extract from our…

    salesforce, AppExchange, Salesforce Video, Video, Business
    Cyntexa Jul 18, 2023
    1,081  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.