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

    6 Best Practices While Implementing Salesforce Sales Cloud

    Blog in Sales, Salesforce Cloud Platform

    Sales Cloud is one of the most prominent offerings in the Salesforce ecosystem and has a proven track record of transforming the sales pipeline and…

    API, AppExchange Apps, Automated Workflows, Built-in APIs, Business Needs
    Carol May 6, 2022
    5,311  Views

    Why Should you Hire a Salesforce Pardot Consultant: Key Reasons to Know

    Blog in Salesforce

    Are you finding Salesforce Pardot Implementation a daunting task? Don’t worry. We are here with our complete guide on Salesforce Pardot Consultants and why should you hire them.    What…

    Marketing Automation, Marketing Campaigns, Marketing Cloud, Marketing Cloud Functionality, Marketing Qualified Leads
    connect@codinix.com Mar 26, 2023
    2,097  Views

    MuleSoft's New AsyncAPI Support Enhances AI-Powered Customer Interactions

    Blog in Others

    MuleSoft has launched an open beta for AsyncAPI support in its Anypoint Platform to facilitate the adoption of event-driven architectures (EDAs). This feature enables businesses…

    API Design, API Specifications, Application Development, AsyncAPI Support, Configuration-Driven
    Cloudmetic Jul 18, 2024
    890  Views

    Popular Salesforce Videos

    Salesforce Careers - Why Consider A Career In Salesforce

    Salesforce Careers - Why Consider A Career In Salesforce

    Video in Salesforce Stories

    This Salesforce Training Video will help you understand about Salesforce, Salesforce market situation, Salesforce job trends, Salesforce career options and how Salesforce is a safe…

    Salesforce Careers, Certified Salesforce Admin, Salesforce CRM, Salesforce Tutorials, Salesforce Admins
    Simplilearn Apr 24, 2019
    2,123  Views
    Practice Test and Questions for Salesforce Platform App Builder Certification Exam

    Practice Test and Questions for Salesforce Platform App Builder Certification Exam

    Video in Salesforce Certifications

    In this video, Shrey provides a practice test for the candidates who are preparing for the Salesforce Platform App Builder Exam. This test boosts your…

    Salesforce Training, Salesforce Tutorial, Salesforce Certifications, salesforce, App Builder
    S2 Mar 23, 2022
    1,861  Views
    Work.com – Release Readiness LIVE, Summer '20 | Salesforce

    Work.com – Release Readiness LIVE, Summer '20 | Salesforce

    Video in Salesforce Stories, Salesforce Products

    Work.com is an online set of applications, resources, and content designed to help the entire workplace get back to business after the Covid-19 crisis. This…

    Workdotcom, Summer 20, COVID-19, Summer '20 Release, Salesforce Release
    Pooja Aug 14, 2020
    1,499  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.