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 use Record types in a test class in Salesforce?

    Tagged: Account, Record Types, Test Class in Salesforce

    • Salesforce® Discussions

      How to use Record types in a test class in Salesforce?

      Posted by Yogesh on November 8, 2019 at 1:04 PM

      i have a requirement where i have  to use  a specific record type name while inserting a record.how can i achieve it ?

      Prachi replied 6 years, 1 month ago 2 Members · 1 Reply
      • Account
      • Record Types
      • Test Class in Salesforce
    • 1 Reply
    • Prachi

      Member
      November 8, 2019 at 4:18 PM

      Hi Yogesh,

      Try this-

      Schema.SObjectType.sObjectApiName.getRecordTypeInfosByName().get('Record Type Name').getRecordTypeId();

      example

      system.debug(Schema.SObjectType.account.getRecordTypeInfosByName().get('person').getRecordTypeId())

      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

    Image Uploader: An Amazing Lightning Component

    Blog in Others

    This is the documentation to create a lightning component to upload pictures to a standard salesforce object which in this particular case is the Products.…

    Client-Side Controller, Lightning, Lightning App Builder, Lightning Component, Salesforce App Builder
    Parantap Jun 18, 2019
    15,217  Views

    Salesforce Marketing Cloud Hacks You Must Try

    Blog in Salesforce Cloud Platform

    For any Marketing Cloud professional, it is important to know the ins and outs of the product so it can be used to its full…

    Automation Studio, Brand Builder, Business Unit, Businesses, Campaign
    360 Degree Mar 2, 2022
    2,220  Views
    Salesforce Lightning Bolt

    Salesforce Lightning Bolt: Create Gen-next Portals At Lightning Speed

    Blog in Lightning

    Ever since the launch of Community Cloud in the year 2013 it has received overwhelming responses from business ranging from small startups to big enterprises.…

    AppExchange, B2B e-commerce, Collaboration Platform, Community Cloud, CRM
    Algoworks Apr 28, 2020
    1,940  Views

    Popular Salesforce Videos

    What Is Loyalty Management in Salesforce?

    What Is Loyalty Management in Salesforce?

    Video in Salesforce Training

    Loyalty Management is a strategy employed by companies to focus on acquiring, engaging, and retaining customers. Have a glance at this extract to discover what…

    Salesforce Training, Salesforce Tutorial, Customer Relationship Management, customer service, Salesforce Learning
    Cyntexa Nov 16, 2022
    1,306  Views
    Salesforce CRM Services offered by Melonleaf Consulting

    Salesforce CRM Services offered by Melonleaf Consulting

    Video in Salesforce Consultant

    Melonleaf Consulting offers customized and configured Salesforce CRM Solutions and Services that can revolutionize your business. Experience the power of top-notch and highly effective Salesforce…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Consulting, Salesforce CRM
    Melonleaf Jul 13, 2023
    1,060  Views
    Happy 2021 to the Salesforce Ohana

    Happy 2021 to the Salesforce Ohana

    Video in Salesforce Stories

    As 2020 comes to a close, the challenges of the past year give way to hopes of a new year full of love, cheer, &…

    Salesforce Community, Salesforce Ohana, Salesforce Guide, Salesforce Video, Salesforce Help
    Pooja Jan 7, 2021
    1,495  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.