Admins / Developers

Salesforce Object Key Prefix List

By Andreea Doroftei

When it comes to navigating to specific records in Salesforce or accurately manipulating data, nothing is more straightforward than using the Salesforce Record ID.

Whether it is the 15- or 18-character one, the first three characters of the ID serve as an identifier for the object type that the record belongs to.

Key Prefix List

Here are some of the commonly used Salesforce objects and their key prefixes:

Object Key PrefixesSalesforce Object
001Account
002Note
003Contact
005User
006Opportunity
500Case
701Campaign
007Activity
00BListView
00DOrganization
00EUserRole
00GGroup
00IPartner
00OReport
00PAttachment
00QLead
00TTask
00UEvent
00XEmailTemplate
00eProfile
00hLayout – Page Layout
01sPricebook2
01uPricebookEntry
01tProduct2
00kOpportunityLineItem
00lFolder
00vCampaignMember
01ZDashboard
01aDashboardComponent
02cSharing Rule
01pApexClass
01qApexTrigger
03uUserPreference
800Contract
801Order
802OrderItem
806Approval

Retrieve the List of Key Prefixes From Your Org

Considering that no Salesforce org has the exact same objects, and you may be looking for the key prefix of a custom object and rather than a standard one from the list above, the EntityDefinition has got you covered! This object provides data about both custom and standard objects, including the KeyPrefix information. With a simple SOQL query, you can retrieve the information you need directly from your org:

SELECT Label, KeyPrefix FROM EntityDefinition

Depending on how many objects you have in your org, the query above might result in the following error:

EXCEEDED_ID_LIMIT: EntityDefinition does not support queryMore(), use LIMIT to restrict the results to a single batch.

If you are facing this error, you can either use the LIMIT clause, as the error message suggests, to only retrieve a maximum of two thousand results, or alternatively, leverage the WHERE clause to filter by Label or DeveloperName, for example, if you need the prefix of a specific object.

  • SELECT Label, KeyPrefix FROM EntityDefinition LIMIT 100
  • SELECT DeveloperName, KeyPrefix FROM EntityDefinition WHERE Label = 'Your Object'

When to Use Salesforce Object Key Prefixes

Formulas, Validation Rules, or Automations

Object prefixes are very useful when it comes to user and queue criteria for objects such as cases or leads. You could create a formula field for this use case, depending on the situation and preference.

Since the user and queue (group) are two different objects, it becomes really easy to have a Salesforce Flow execute – for example, only when a lead is owned by a user and other criteria are met.

Additionally, if you are using Tasks and Events in your org, you might consider leveraging the object key prefix in relation to the WhatID. For example, if there is an automation to be triggered every time a task is completed and is related to an opportunity, but a different automation when the task is related to a custom object record, you can use the KeyPrefix in a Decision element within a Salesforce Flow to easily determine the path that will be taken based on the record.

Summary

Finally, prefixes are an easy way to identify most Salesforce objects. As you continue to work with Record IDs, chances are that at some point, you will know most of them by heart. You also have the option to use a query and find out this information about an object in a few seconds, and further use it even in automations.

Have you used the Object Key Prefixes for any use case or process? Let us know in the comments below!

The Author

Andreea Doroftei

Andreea is a Salesforce Technical Instructor at Salesforce Ben. She is an 18x certified Salesforce Professional with a passion for User Experience and Automation. 

Leave a Reply