Wednesday, October 3, 2012

Salesforce Record ID's

Apart from being what many regard as long, useless numbers; Record IDs in Salesforce.com can in fact be very useful, whether you’re a simple user of the system, or an advanced developer looking to extend your Force.com applications.
Each table and data record in the Salesforce.com system has a unique ID field assigned to it. You can’t remove the unique ID, nor can you change it; it’s something that is system generated each time a new record is inserted into the application. Unique IDs are in fact very useful for anyone designing and developing applications on the Force.com platform. To understand this better let’s look at a real example:
  • As an exercise, sign into your Salesforce.com org and find an Account record to work with (In my case, I am using a developer org with some test data pre-loaded)
  • I’ve selected the Edge Communications account, which has an ID of 001A0000006Vm9u as you can see from the page snippet below
Salesforce.com Unique ID


So why are these IDs useful?
Basically, they provide a consistent, foolproof way to refer to a data record; right down to the ability to copy and paste a unique ID as a URL into the page address after the salesforce.com/ part of the address.
What many do NOT know is that these IDs, though unique, are also case-sensitive. This can present a challenge when you are using the ID values in external systems such as MS Excel or database systems.
To demonstrate my point, try this URL: http://na7.salesforce.com/001A0000006VM9U
(substitute the na7 part of the URL for your own instance)
It almost certainly will not work, and you’ll see an error message (unless, by some fluke this ID actually exists in your system). To drive home the point, 001000000009Abc is *not* equal to 001000000009ABC, at least not in Salesforce.com ID terms.
Useful information: Record ID values are copied without modification from a production org when a sandbox is created, but it is almost certain that any subsequent records created in the two orgs will have different ID values.

Now, you can do some interesting things with ID values. For example, the following characters (entered after the salesforce.com part of the web address) will place you in a new Contact record page: /003/e – Try it!
Similarly, these characters will navigate you directly to the Campaign Home Page: /701/o
Using just the 3-char prefix will bring you to the default view for that object e.g. /800
Entering a known record ID (15 or 18 characters) will direct you straight to the details page of that record: /00QA0000004wjDt

Here are some more useful shortcuts:
Useful tip: The 1st 3 characters of an ID indicate the object type (i.e. table name)
  • 001 = Account
  • 003 = Contact
  • 005 = User
  • 006 = Opportunity
  • 00D = Organization
  • 00e = Profile
  • 00E = UserRole
  • 00Q = Lead
  • 00T = Task
  • 00U = Event
  • 012 = Record Type
  • 015 = Document
  • 01t = Product
  • 500 = Case
  • 701 = Campaign
  • 800 = Contract… and so on
These prefixes never change for standard objects. Custom objects are assigned 3-char prefixes based on internal SFDC rules that we cannot predict. However, even if you’re not a developer or an expert user of Salesforce.com, these unique IDs can provide a quick route to locate and amend data in the Salesforce.com system. Not only that, it’s also quite a fun way to show how much you know about the system and how quickly you can navigate around it.