How to Find Record Type Name by ID in Salesforce

Published: May 30, 2025
TABLE OF CONTENTS

    Find Record Type name by Id in Salesforce

    In Salesforce, Record Types help define different processes and layouts for various business needs. But when working with code, integrations, or data tools, you might come across just the Record Type ID—with no clear idea of what it refers to.

    Whether you’re debugging an issue, building automation, or reviewing records, knowing how to match that ID to a readable name or its DeveloperName can save time.

    This blog walks you through different ways to find the Record Type name using SOQL queries, Apex code, and the Salesforce user interface. These methods work the same way in both Salesforce Classic and Lightning, no matter the version.

    SOQL Method to Get Record Type Name

    Use SOQL when you already know the target object (e.g., Account, Opportunity), and you have permission to run queries against the RecordType object in your org. This method is ideal for quick lookups via the Developer Console or any API-driven tool.

    SELECT Name, DeveloperName FROM RecordType WHERE Id = '012dL000006LH41QAG'
    • Name returns the label of the record Type (what appears in the UI).
    • DeveloperName returns the stable API name, which remains constant across translations and language settings.

    SOQL Method to Get Record Type Name

    How to Run

    • Developer Console: Open the Query Editor, paste the SOQL, and click “Execute.”

    Best Practices

    • Always reference the DeveloperName in automation, as it remains the same across languages and orgs.
    • Filter by DeveloperName instead of hardcoding IDs (e.g., WHERE DeveloperName = ‘Partner’). Hardcoded IDs break when migrating between Salesforce environments.
    • Check for SOQL limits in bulk operations or triggers.

    Use Apex to Get Record Type Name

    Apex provides a lightweight, governor-limit-friendly way to retrieve Record Type details using the Schema class. This approach is ideal for Apex triggers, utility classes, or Salesforce Flows.

    You can get a Record Type’s user-facing name directly from its ID without using a SOQL query. Salesforce caches describe information for each object in memory during a transaction. By accessing Schema.SObjectType.<ObjectName>.getRecordTypeInfosById(), you get a map of Record Type IDs to their corresponding RecordTypeInfo objects. Calling .getName() on the desired entry returns the label.

    Example 1: Get Record Type Label and Developer Name

    // Retrieve Record Type ID from an SObject's RecordTypeId field  
    
    Id rtId = '012dL000006LH41QAG';  
    
    // Fetch RecordTypeInfo map for the Account object  
    
    Map<Id, Schema.RecordTypeInfo> rtInfoById =   
    
        Schema.SObjectType.Account.getRecordTypeInfosById();  
    
    // Extract RecordTypeInfo using the ID  
    
    Schema.RecordTypeInfo rtInfo = rtInfoById.get(rtId);  
    
    if (rtInfo != null) {  
    
        // Get user-facing label  
    
        String recordTypeName = rtInfo.getName();  
    
       // Get developer name (API identifier)  
    
        String developerName = rtInfo.getDeveloperName();  
    
        System.debug('Record Type Label: ' + recordTypeName);  
    
        System.debug('Record Type API Name: ' + developerName);  
    
    } 

    Example 2: This is a shorter version that does the same thing—gets the Record Type label using its ID—but all in one line.

    
    String recordTypeName = 
    Schema.SObjectType.Account.getRecordTypeInfosById().get('012dL000006LH41QAG').getName();
    System.debug('Record Type Label: ' + recordTypeName);
    

    When to Use This Approach

    1. Flows and Low-Code Automation: Use this logic in invocable Apex methods to avoid exhaust SOQL limits in Salesforce Flows.
    2. Managed Packages: Reference Record Types by Developer Name instead of IDs to ensure compatibility across orgs. Example:
    String devName = 'Customer_Account'; // Use a constant or custom setting  
    
    Schema.RecordTypeInfo rtInfo =   
    
    Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get(devName);  

    3. Dynamic Scenarios: If you only know the RecordType ID (not the object), combine it with getSObjectType():

    String sObjectType = recordId.getSObjectType().getDescribe().getName();  
    
    String devName = Schema.getGlobalDescribe().get(sObjectType)
    .getRecordTypeInfosById().get(recordTypeId)  
    .getDeveloperName();

    Best Practices:

    • Avoid Hardcoding IDs: Use Developer Names or custom metadata to store Record Type identifiers, ensuring portability across environments.
    • Performance: Schema methods are cached, but avoid redundant calls in loops.
    • Governor Limits: Bypasses SOQL queries, preserving limits for critical operations.
    • Dynamic Flexibility: Enables code reuse across objects without hardcoded references.
    • Automate: Leverage SOQL or Apex for bulk operations instead of manual lookups.

    Can You Find a Record Type Name by ID in Salesforce’s UI?

    If you happen to know which object the Record Type belongs to (e.g., Account, Opportunity), you can try this hack:

    https://yourdomainname.lightning.force.com/lightning/setup/ObjectManager/Account/RecordTypes/0123X0000001abcQAA/view

    For developer edition: 

    https://yourdomainname.develop.lightning.force.com/lightning/setup/ObjectManager/Account/RecordTypes/012dL000006LH41QAG/view

    Replace yourdomainname with your Salesforce instance (e.g., mycompany). Replace Account with the object’s API name (e.g., Custom_Object__c). Use the 18-character Record Type ID.

    Paste it into your browser.

    If you have permission to view the Record Type and it’s active, Salesforce will open its details page and show you the name.

    If you prefer working in Excel, tools like XL-Connector allow you to pull Record Type metadata directly into a spreadsheet by running a simple SOQL query—including IDs, labels, and DeveloperNames—making it easy to read, share, or update.

    XL-Connector to fetch Record Type in spreadsheet XL-Connector to fetch Record Type in spreadsheet

    Conclusion

    In Salesforce, it’s often necessary to find the Record Type name when all you have is the ID—especially during tasks like automation, troubleshooting, or reviewing configurations. Although working with Record Type IDs is common, knowing how to trace them back to their names adds clarity and efficiency.

    The right method—whether using a SOQL query or Apex—depends on the context. To keep your work flexible and easier to maintain, avoid hardcoding IDs and use stable identifiers like DeveloperName instead.

    Posted in
    Rajeshwari Jain
    Rajeshwari Jain
    Banner-blog-ROCKET-2024-2

    Xappex CRM data management solutions

    G-Connector for Salesforce

    Connect your Salesforce data to Google Sheets in a two-way sync.

    XL-Connector for Salesforce

    Connect and export your Salesforce data to Excel.

    Looker Studio

    Looker Studio for Salesforce

    Connect Salesforce reports and queries to your Google Data Studio dashboards.

    Excel Merge

    Excel Merge

    Calculate advanced Excel models. Generate Excel documents based on Salesforce data. All with a single click from a Salesforce record page.

    XL-Connector 365

    Connect and sync Microsoft Excel on all platforms with Salesforce.