The importance of record IDs

Why do we have a separate section on record IDs? Once we master them, most of the data operations are a piece of cake. The record ID is a unique identifier of the record. The record ID is similar to the primary ID and foreign ID in a database table.

The Salesforce.com record IDs are not just a bunch of random numbers, but have valuable information that can help us.

18-character and 15-character IDs

Force.com uses two types of IDs, 18 character and 15 character. When we use the ID from the URL it is 15 characters, however, when we use the data loader we get 18 character IDs.

The 15-character ID is case sensitive while the 18 character ID is not case sensitive. The 18-character ID is used to migrate data from legacy systems or spread sheets, which do not recognize case-sensitive IDs. Both the IDs work with Force.com and point to the same record. However, if we are to migrate data from the spread sheets or export data to the spread sheets we have to use 18-character IDs.

There are three ways of getting the record ID, they are as follows:

  1. URL of the record detail page.
  2. By running a report on the object.
  3. Data loader (API access).

URL and report will always return the 15-characters IDs while the data loader and the API return the 18-digit IDs. API, however, accepts both 15-character and 18-character IDs.

Let us now explore what we can gain from IDs in the URL.

Exploring the URL format

The easiest way to study the record ID is by understanding the standard Salesforce objects. These IDs are fixed and are of similar format across the Salesforce organization. Every custom object will have a fixed pattern, but will be unique to individual organizations only.

For the purpose of an example we will study the record ID of opportunity object. Open an opportunity record as shown in the following screenshot:

Exploring the URL format

Tip

If you do not find it on display, please select the Standard Sales Application using the drop-down in the corner.

The record ID is seen in the address bar of the browser as shown in the following screenshot:

Exploring the URL format

Let's observe the format of the URL of the address bar carefully, the URL is made up of different things as shown in the following screenshot:

Exploring the URL format

Let us now look at the different parts of the URL separated in the preceding screenshot.

  • Instance name: The first part of the URL is the instance name. Salesforce.com provides multiple instances of the server and the instance name varies depending on the time and location from where you create the ID. For the full list of instance name and their status please visit:

    http://trust.salesforce.com/trust/status/

  • Salesforce Server URL: This is common for all the record IDs.
  • Record ID: The third part of the URL as seen in the preceding screenshot is the Record ID. The format of the URL is common for all the detail page of the records across the organizations. We will be looking at the Record ID in greater detail in the next section.

Record ID

One important thing to note is that the record ID is case sensitive. So 00690000003zRfq is not equal to 00690000003ZRFQ. There will be a unique ID per organization, no two records will have same ID. When we migrate data from one organization to another, the IDs are changed. The record ID is further split into two parts as shown in the following screenshot:

Record ID

The first three characters of the record ID are the object identifiers, which help us to identify the object of the record.

The remaining characters are the unique record ID to identify the record. All the objects thus have three-character encoded ID, which is a prefix to their record ID elsewhere.

The following table shows us the three character prefixes and the objects that they are associated with:

Prefix

Object Name

001

Account

003

Contact

005

User

006

Opportunity

00e

Profiles

00Q

Leads

00T

Tasks

00U

Event

015

Document

01t

Product

500

Case

701

Campaign

800

Contract

These prefixes for the standard objects are the same across all the Salesforce organization. Now let's play with the URL a bit. If we wish to land on the list view of the standard object, all we need to do is append a /o against the object prefix example for the account object we need to add 001/o.

The final Salesforce URL in this case would be:

Record ID

Note

The instance name for every organization would be different. The name depends on the geography and the time when the Salesforce account is created, please check the instance name for your organization.

This will open the list view or the tab view of the object, similarly we can change the prefix to any standard object.

When we change the /o to /e it automatically opens the edit page for a new account:

Record ID

This will open the edit page for the account directly. If we add the /e in front of a record ID, we get the update detail page for the record, for example, let's say we want to open the opportunity edit page from our original example.

Record ID

Now if we add the /e in front of the URL, we get:

Record ID

This will automatically open this opportunity for editing; try adding a /e against any record URL and we will get the edit page for the record with all the existing data pre-filled with information.

Only when we create the full-copy sandbox of the production organization, do we get similar IDs in productions and sandbox only once.

Record ID in the field is not editable even in code. We cannot include it in DML for insert, but will be useful for DML of update and delete.

Summarizing record IDs

Let us recap some important points we learned about record IDs:

  • A record ID is similar to the primary or foreign key in a database
  • Record IDs are case sensitive on Salesforce.com
  • 18-character IDs are case insensitive
  • Every record ID has a prefix of the first three characters
  • Every record in multiple and similar organizations have a different ID
  • IDs are similar only for the first time when we have a full-copy sandbox of a production organization
  • 18-character IDs are used for migrating data from a legacy system that is case insensitive
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset