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

    Customer Engagement

    4 Best Ways to Improve Customer Engagement with Salesforce Field Service

    Blog in Lightning, Salesforce

    Every client has experienced the annoyance of booking a field service appointment: you're put on wait, scheduled for the following month, and informed someone would…

    Automated System, Business, Chatbots, Client Needs, Client Portal
    Cynoteck Jul 8, 2022
    3,238  Views
    Unveiling the Key Features of Salesforce Marketing Cloud and Pardot

    Unveiling the Key Features of Salesforce Marketing Cloud and Pardot

    Blog in Salesforce

    In the realm of digital marketing, staying ahead of the curve is imperative. Businesses constantly seek innovative solutions to streamline their marketing efforts, engage with…

    Automation, Campaign Performance, Customer Engagement, Customer Relationships, Customer Success
    Infodriven Apr 8, 2024
    1,136  Views
    Device Authorization Flow

    OAuth 2.0 Device Authorization Flow in Salesforce

    Blog in Salesforce Stories

    For input-restricted devices that connect to the Internet, instead of authenticating the user directly, the device prompts the user to go to a link on…

    API, App, Authentication Flow, Authentication Process, Authorization
    Nikhil Kumar Nov 11, 2022
    4,009  Views

    Popular Salesforce Videos

    Introducing KaseSync: An Innovative Community-CRM Connector! | Salesforce

    Introducing KaseSync: An Innovative Community-CRM Connector! | Salesforce

    Video in Salesforce Products

    KaseSync, is an innovative community-CRM connector designed to create seamless bi-directional data sync between platforms. Learn how exactly it improved self-service and boosts community engagement. 

    Salesforce Training, Salesforce Tutorial, salesforce, CRM, Salesforce Learning
    Amisha Makkar Dec 29, 2022
    1,916  Views
    Salesforce Customer 360 for B2C Solutions

    Salesforce Customer 360 for B2C Solutions

    Video in Salesforce Stories

    Learn about Slalom's approach to creating integrated customer-focused experiences spanning B2C Commerce, Marketing Cloud, Service Cloud, Experience Cloud, and beyond. Watch this video by Salesforce…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Video, Customer 360
    Prafull Jan 25, 2022
    4,036  Views
    Salesforce Service Cloud Telephony

    Salesforce Service Cloud Telephony

    Video in AppExchange

    Natterbox CTI and Telephony inside Salesforce ServiceCloud. Transform your telephony experience and empower your agents with fast and personalised support.

    Salesforce Service Cloud, Salesforce Cloud, Best Salesforce Tutorials, Salesforce Service Cloud Training, Salesforce Service Cloud Demo
    Ian Feb 20, 2019
    1,962  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.