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

    Driving Online Communities With Dynamic Gamification | Salesforce

    Blog in Salesforce customization

    Gamifying your online community is an effective way of driving highly-engaging user experiences. Did you know that the global gamification market is projected to grow…

    Businesses, Community Experiences, Community Gamification, Criteria-based Scoring, Custom Objects
    Shubham Dec 30, 2021
    4,532  Views
    Salesforce Data Import Wizard

    Using a Salesforce Data Import Wizard - All you Need to Know

    Blog in Data, Salesforce, Salesforce Training

    Salesforce is an integrated technology platform that enables companies to automate business processes. It is used as a software application that delivers Structured Query Language…

    Automate Business Process, Cloud Business Solutions, Cloud Computing, Collaboration, Create Record link
    Amanda Dudley Sep 1, 2021
    3,221  Views

    Salesforce Advisory Services: Finally Explained in Detail

    Blog in Salesforce Consultant

    If Salesforce is out-of-the-box and ready to use, why does it even come to custom development? Implementing Salesforce CRM sounds like a perfect solution to…

    Assessment, Best Practices, Business Requirements, Business Strategy, Challenges
    Sparkybit Sep 21, 2023
    1,613  Views

    Popular Salesforce Videos

    Add Styles and Data to a Salesforce Lightning Web Component

    Add Styles and Data to a Salesforce Lightning Web Component

    Video in Lightning

    After completing this unit, you’ll be able to: Use CSS and Lightning Design System with a component. Get data from a Salesforce org. Deploy your…

    Salesforce Training, Salesforce Lightning, salesforce, Salesforce Org, Salesforce Video
    Rupal Kakkar Jul 21, 2021
    5,174  Views
    Salesforce Standard vs Custom Objects Explained

    Salesforce Standard vs Custom Objects Explained

    Video in Salesforce Admin

    Salesforce, a leading customer relationship management (CRM) platform, offers both custom and standard objects to organize and manage data effectively. Standard objects are pre-built components…

    Salesforce Standard Objects, Salesforce Custom Objects, Salesforce Lead Objects, Custom Objects, Custom Object in Salesforce
    ENWAY Jul 1, 2024
    488  Views
    What is Apex? | Way to become a Salesforce Developer | Salesforce Development Tutorials

    What is Apex? | Way to become a Salesforce Developer | Salesforce Development Tutorials

    Video in Salesforce Training

    This video will provide you a complete path to become a Salesforce Developer. It includes very important and beneficial topics like Apex, Visualforce, Lightning.  …

    Salesforce Apex, Salesforce Developer, Salesforce Lightning, Visualforce, Salesforce Video Tutorials
    Eshu Kumar Feb 14, 2020
    2,347  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.