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

    application solution

    Popular Salesforce Blogs

    Benefits of Salesforce Einstein Analytics For Nonprofits

    Blog in Salesforce Einstein

    Sometimes it gets challenging for your nonprofit organization on how your campaigns are performing, the impact you are creating, and the funds getting generated for…

    Benefits of Einstein, Boosting Team Collaboration, Business Intelligence Tools, Business Model, Campaign
    Apphienz Apr 14, 2022
    2,088  Views

    Unlocking Business Potential with Salesforce Consulting Services

    Blog in Salesforce Consultant

    In today's competitive market, effective Salesforce consulting services are essential for businesses aiming to leverage Salesforce's full potential. With its extensive features and capabilities, Salesforce…

    Business Potential, Data Migration, Salesforce Automation, Salesforce Consulting, Salesforce Customization
    Nishant Aug 5, 2024
    488  Views

    Mastering Email Deliverability in Salesforce Marketing Cloud

    Blog in Salesforce Cloud Platform

    In today’s world of digital marketing, an email's journey from your campaign to your subscriber's inbox is an important aspect that has a bearing on…

    Best Practices, Content OptimizationContent Optimization, Digital Marketing, DomainKeys Identified Mail, Email Campaigns
    Codleo Feb 20, 2024
    1,295  Views

    Popular Salesforce Videos

    Case Study: Connecting Ferries with Salesforce IoT Explorer

    Case Study: Connecting Ferries with Salesforce IoT Explorer

    Video in Salesforce Integration

    The data that Salesforce IoT Explorer brings to the table helps businesses take real-time business decisions that translates into better customer service. Salesforce, in its…

    Salesforce Integration, Salesforce Data Management, Learn Salesforce, Customer Success, TrailheaDX
    Jogender Apr 19, 2018
    2,724  Views
    Salesforce Customer 360 Audiences Enhancements

    Salesforce Customer 360 Audiences Enhancements

    Video in Salesforce Stories, Salesforce Products

    Salesforce Customer 360 is a tool that allows companies to connect Salesforce apps and create a unified customer ID to build a single view of…

    Salesforce Demo, Salesforce Apps, Salesforce Video, Salesforce Customer 360, Salesforce Learning
    Jogender Dec 9, 2020
    1,924  Views

    Salesforce Video Wall

    Video in Others

    Salesforce approached Obscura with the opportunity to create imaginative media for the 107’ long LED video wall in the lobby of their flagship San Francisco…

    Salesforce Video Wall, Salesforce Stories, Life at Salesforce, Salesforce Tower, Salesforce Office
    Abhay Mar 22, 2018
    2,140  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.