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, 10 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

    Omni-Channel Overview in 2024

    Blog in Others

    Omni-Channel is a Customer Service and console-based Salesforce feature that helps automatically route of different types of work items (such as Leads and Cases) to…

    Capacity, Configuration, Customer Communication, Customer Service, Flow
    Vimera | Andersen Apr 5, 2024
    775  Views
    sales cloud marketing cloud

    How to Import Reports From Salesforce Sales Cloud Into Marketing Cloud Using Imports

    Blog in Data, Sales, Salesforce Cloud Platform

    In Salesforce Marketing cloud we can import data into the marketing cloud in two ways using imports : Objects and   Reports  Here I will explain…

    Automations, Data Extension, Email Address, Email Studio, External Key
    Manish Sep 2, 2020
    12,387  Views
    Business Travel Basics in Salesforce Net Zero Cloud | All You Need to Know

    Business Travel Basics in Salesforce Net Zero Cloud | All You Need to Know

    Blog in Others

    Have you ever wondered what the environmental impact of your business travel is? Well wonder no more, Salesforce has you covered. As part of our…

    Carbon Emissions, Carbon Footprints, Climate Change, Corporate Reputation, CRM Analytics
    Stimulus Consulting Apr 13, 2023
    1,192  Views

    Popular Salesforce Videos

    Why To Sell Your SAAS Application On Salesforce AppExchange ?

    Why To Sell Your SAAS Application On Salesforce AppExchange ?

    Video in Others

    From unparalleled market reach to seamless integration and trusted security, explore the benefits that await SAAS entrepreneurs on Salesforce AppExchange. Watch our latest webinar to…

    Salesforce Developer, Salesforce Integration, salesforce platform, Customer Success, Salesforce Hulk
    Cyntexa Jul 14, 2023
    907  Views
    What are Permission Sets (Object Level Security) in Salesforce?

    What are Permission Sets (Object Level Security) in Salesforce?

    Video in Salesforce Security, Salesforce Training

    In this video, Shrey is not only teaching but also demonstrating Permission Sets used in Salesforce Object Level Security. You will be learning: What are…

    Salesforce Training, Salesforce Tutorial, Salesforce Administrator, salesforce, Salesforce Video
    Abhishek Dec 11, 2020
    2,479  Views
    Prepopulate Field values in Salesforce Lightning Experience Using defaultFieldValues

    Prepopulate Field values in Salesforce Lightning Experience Using defaultFieldValues

    Video in Lightning

    Prepopulate Field values in Lightning Experience Using defaultFieldValues - Spring 20 This video demonstrates the following items: Set Record Type Id Using defaultFieldValues Enforce User…

    Salesforce Training, Salesforce Tutorial, Salesforce Lightning, salesforce, Field Values
    Abhishek Jun 2, 2021
    1,747  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.