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

    Play Around Salesforce Batch Apex And Schedule Apex

    Blog in Others, Salesforce Apex

    Batch Apex Batch Apex classes are beneficial if the task is something to run large jobs like thousands or millions which is exceeded than normal…

    Batch Apex, Database Batchable, Database Query Locator, Developer Console, Salesforce Apex Class
    Archit Aug 2, 2018
    12,316  Views
    What is Salesforce

    What is Salesforce? A Definitive Guide!

    Blog in Salesforce

    Salesforce is a type of software that includes CRM management and workforce management and enables us to manage customer relationships, customer service management, marketing campaigns,…

    API key, Campaigns, Cloud Computing, Component-based Framework, Contacts
    Kalpana Dec 16, 2022
    2,666  Views
    Avoiding Race Conditions

    Avoiding Race Conditions

    Blog in Salesforce customization

    An action function provides a way to submit a form programmatically via a JavaScript function call. When an action function is executed from a JavaScript event…

    JavaScript, JavaScript framework, Race Conditions, Salesforce, Salesforce Customization
    Ravi May 18, 2016
    9,809  Views

    Popular Salesforce Videos

    Being a Sr. Salesforce Consultant | SFDC Consultant Podcast

    Being a Sr. Salesforce Consultant | SFDC Consultant Podcast

    Video in Salesforce Consultant

    What it is like being a Sr. Salesforce Developer at a consulting firm. What a day in Sr. Salesforce Consultant's life looks like. Struggles of…

    Salesforce Developer, Salesforce Consultant, Salesforce Consulting, SFDC, Salesforce Video
    Prafull Aug 4, 2020
    1,880  Views
    Build Better with Salesforce Architects

    Build Better with Salesforce Architects

    Video in Salesforce Training, Salesforce Admin

    A Salesforce Architect is a trusted advisor and leader who partners with business stakeholders and executives to design a vision and architecture for a solution…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Video, Salesforce Learning
    Vivek Apr 28, 2022
    1,981  Views
    How to Find Queries that Target a Data Extension in Salesforce Marketing Cloud

    How to Find Queries that Target a Data Extension in Salesforce Marketing Cloud

    Video in Salesforce Training

    In this video, Cameron Robert shows how to find SQL queries in Automations that affect a specified Data Extension in Salesforce Marketing Cloud. Key Moments:…

    Salesforce Training, Salesforce Tutorial, Salesforce Marketing Cloud, Salesforce Learning, Data Extension
    Cameron Jul 26, 2022
    2,152  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.