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

    salesforce managed packages

    Resolution of Managed Packages - Salesforce DX Developer Guide

    Blog in Others

    Working with Salesforce DX for the resolution of managed packages: First, we create an org and enable the DX version in it that is DEVHUB.…

    App Launcher, Developer Edition, Developer Org, Domain Name, DX Tools
    Anuj Jun 11, 2020
    6,373  Views

    Salesforce Links Einstein GPT and Data Cloud to Flow

    Blog in Salesforce

    Salesforce links Einstein GPT and Data Cloud to Flow to drive the autonomous, intelligent enterprise by integrating AI-generated content with real-time customer data to automate…

    Automate Workflows, Automation, code generation, Complex Workflows, Composing emails
    Apphienz May 30, 2023
    1,205  Views
    Lightning Web Component

    Call Lightning Web Component From a Quick Action in Salesforce

    Blog in Lightning, Salesforce Tutorial

    In Lightning, still, you can't call an LWC component from quick action straightforwardly. An LWC component should be wrapped inside an Aura Component and Aura…

    Aura Component, Immediate Strategy, JS File, Lightning, Lightning Web Component
    Anuj Dec 23, 2020
    16,746  Views

    Popular Salesforce Videos

    How to Use Customer 360 | Salesforce

    How to Use Customer 360 | Salesforce

    Video in Others, Salesforce Stories

    See how Salesforce Customer 360, our entire portfolio of technology, unites your team with company data on one integrated CRM platform, delivering the personal experiences…

    salesforce, Artificial Intelligence, Salesforce Video, Customer 360, Salesforce Customer 360
    Rupal Kakkar Jun 3, 2020
    1,482  Views
    How to Build an Offline Salesforce App, Part 1: Authenticate with Salesforce

    How to Build an Offline Salesforce App, Part 1: Authenticate with Salesforce

    Video in Salesforce Implementation, Salesforce Apps

    This video tutorial will guide you through the following steps: * Integrating the Salesforce connector * Modifying the login screen and process * Authenticating with…

    salesforce training videos for beginners, Salesforce Beginner Tutorial, Salesforce Tutorial for Beginners, Salesforce Apps, Salesforce Data Management
    Jogender Mar 7, 2018
    2,352  Views
    How To Use Journey Builder In Salesforce Marketing Cloud | Salesforce Tutorial

    How To Use Journey Builder In Salesforce Marketing Cloud | Salesforce Tutorial

    Video in Marketing, Salesforce Cloud Platform

    How to use Journey Builder in Marketing Cloud. This video will cover the following points - 1. Introduction Get a brief introduction to Journey Builder…

    Salesforce Training, Salesforce Tutorial, Salesforce Marketing Cloud, Salesforce Video, Salesforce Learning
    Algoworks May 5, 2021
    2,070  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.