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 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, 11 months 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

    Popular Salesforce Blogs

    Salesforce Consulting: The Potential of Salesforce Consulting Services

    Blog in Salesforce, Salesforce Consultant

    Salesforce Consulting Services is trending due to the fact that they're expanding their support options to a wide variety of customers, meaning they're able to…

    Apps, Automating Sales and Marketing, Business Challenges, Business Environment, Business Goals
    Hennery cavil Nov 28, 2022
    2,938  Views
    What is the Non-Profit Success Pack in Salesforce?

    What is the Non-Profit Success Pack in Salesforce?

    Blog in Salesforce

    The Salesforce Non-Profit Success Pack (NPSP) is a free solution available to nonprofits through the Salesforce AppExchange. It was created to help nonprofits use CRM…

    fundraising, Fundraising Campaign Management, Fundraising Campaigns, IT Teams, Lead Nurturing
    NAVDITA DAHIYA Mar 31, 2023
    1,679  Views

    How Salesforce AppExchange Makes Business Solutions Easier

    Blog in Others

    In today’s fast-paced business environment, organizations need flexible, scalable solutions to meet evolving demands. Salesforce AppExchange has become a vital platform for businesses seeking ready-to-use…

    Anna Nov 11, 2025
    702  Views

    Popular Salesforce Videos

    Introduction to Salesforce Orchestrator

    Introduction to Salesforce Orchestrator

    Video in Salesforce Training, Salesforce Workflow

    Flow Orchestrator was created so admins like you can quickly create sophisticated multi-user, multi-step automated business processes with clicks, not code. Experienced Salesforce Admins will…

    Salesforce Training, Salesforce Tutorial, salesforce, User Experience, Salesforce Admins
    Prafull Oct 19, 2021
    4,091  Views
    Salesforce Apps: Managed vs. UnManaged Package Importance from Lederhosen Salesforce

    Salesforce Apps: Managed vs. UnManaged Package Importance from Lederhosen Salesforce

    Video in AppExchange

    Salesforce has Two Types of Packages ( Tabs, Objects, Software ) you can load: Managed & UnManaged. This video describes both. The advantage of a…

    Salesforce Apex, Salesforce Consultant, Salesforce Apps, Salesforce Packages, Salesforce Objects
    Pooja Jan 12, 2018
    3,438  Views
    Salesforce Career Path 2022 | How to Make Career in Salesforce

    Salesforce Career Path 2022 | How to Make Career in Salesforce

    Video in Salesforce Training

    In addition, Salesforce Developer is one of the 10 best jobs on Indeed's Best Jobs. As businesses embrace the future of mobile, big data, IoT,…

    Salesforce Training, Salesforce Tutorial, Salesforce Developer, Salesforce Video, Salesforce Career
    Jogender Oct 27, 2021
    2,128  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.