Categories
General Objects Records Salesforce Data Salesforce Guides

Difference Between 15 and 18 Digit Record IDs on Salesforce

Salesforce is the global leader in CRM solutions. Their one-stop-shop for all your customer needs is a fast and effective way to manage clients.

Introduction

Let’s consider the day in the life of a carpenter. A person with many tools. A saw, hack, tape measure, clamps, screwdrivers and much more. Imagine having to get to work, but all of these tools are scattered in different rooms.

The productivity is slower and the work is done at snail pace.  The carpenter thus invests in a toolbox. A single entity to hold all the tools in one place.

Now imagine every business owner as a carpenter. They need to manage tools like marketing, sales, commerce, profiles, etc. The integration of all of these into one platform is what Salesforce is able to achieve. 

This is one of the leading customer resource management (CRM) platforms that let you enhance company sales, all using one platform. It allows the many departments to have one single unified view to promote ease of work and provide better communication between departments. 

Each interaction with a potential customer is noted into the platform which further helps the sales team track it’s progress. The leads of each department can also access this information so all members of the company are on the same page, with each customer. One a very fundamental level, Salesforce brings all the limbs of the company to have a consistent overview of each and every customer.

The science behind Salesforce.

Source: www.salesforce.com

Salesforce is the most functional form of SaaS. ‘Software as a service’ is a provision where a third party software is used to host and manage multiple apps. In this case, they use cloud-computing to setup many applications within a single platform.

The advantage of cloud computing is that there are no physical servers and all the data is stored on a common online source. This allows the members of the company to access the information about the customers from anywhere on the planet.

The founding principle of the platform is to boost sales. Let’s take an example of a lead generated at the helpline or a call center of a company. This lead this entered into the platform for the sales team to keep a track off. These multiple opportunities are then followed up by the sales team until a meaningful result is achieved.

These contacts are then archived into the platform so the other departments like marketing and support can monitor them. Each customer has their own unique section that entails all the information that would be relevant for the company to service these clients. 

Recently with the boom of artificial intelligence, Salesforce has implemented the same on the platform. This helps to provide suggestions and enables better forecasting.

What is the function of a Record ID?

Now that you understand the functioning of the platform. It’s easier to dive deeper. Every time a new customer is added into the platform, there is a unique record ID generated for this customer. This implies that, at the time of record creation, the individual is assigned an ID that does not change until the record if completely destroyed.

Even if these records are temporarily deleted, these IDs will be the same when this record is restored back. Once the record is deleted and left in the bin for more than 30 days, then this ID will be available for re-use. This is used to track the record of each user, by the various limbs of the company.

Record ID is usually a 15 digit ID that can be seen on the browser window URL when that specific entry is open.  These 15 digit IDs are made up of 62 case-sensitive strings. They can contain lower case letters (a-z), upper case letters (A-Z) and numerical value (0-9). Two different IDs can be just separated by a change in the case of a single alphabet.

For example; in the dummy URL below:

http://example-user-name.salesforce.com/000111222XXXAAA

The record ID will be “000111222XXXAAA”

This record ID will not be similar for any two records making it a unique 15 digit code. 

How is this different from the external ID?

One can easily confuse an external ID for a record ID. This is are very different. Outside of the salesforce dashboard, these records may be displayed on an external system. The company might wish to assign a unique ID of its own to identify each user.

This entry can be a customer number, a phone number, membership ID, etc. In that case, the platform can be used to assign that to the “External ID” attribute. This means the information can be sorted and edited using this new field as a search parameter.

Difference between 15 and 18 digit record IDs.

Now that you understand how the record ID works, you might have noticed they also occur in 18 digit values at times. If you are using the salesforce classic, you will notice a URL like this one below:

URL: http://example-user-name.salesforce.com/000111222XbbAAa

Thus the record ID is 000111222XbbAAa (15 digits)

But, if you are using a Salesforce Lightning. You will notice a URL like this one. 

URL: http://example-user-name.salesforce.com/lightning/r/Case/000111222XbbAAaQ12/view?0.source=alohaHeader

Here the record ID is 000111222XbbAAaQ12 (18 digits)

These serve the same function as that of the 15 digit ID, except one primary difference. The 15 digit record ID is case sensitive. While the 18 digit ID is case insensitive.

This means the capital-letter-A and small-letter-a hold different values in the case of a 15 digit ID.

Why is there a need for two different record IDs?

The obvious question is: if they both serve the same purpose, then what is the point of having two different ID types? The answer lies in the case sensitivity of these two. There are many systems where the application of a case sensitive ID can lead to duplication. For example platforms like access and excel do not recognize case sensitive ID. So here capital-letter-A and small-letter-a will host the same value. This can lead to a mismatch of record IDs. To solve this problem, the 18 digit code is used. These case-safe values are also needed to access all kinds of API actions. These 18 digit IDs are formed by adding a suffix to the existing 15 digit ID.

How to convert the 15-digit ID to an 18-character version?

The reverse is simple, If you need to convert an 18-digit ID to a 15-Digit ID, all you need to do is eliminate the last three additional characters. However, Salesforces recommends that to call API, create and edit data — one should use the 18 digit ID to avoid any discrepancies.

Any of the API versions after 2.5 use the 18-Digit ID only. The reports read the database and displace the 15 digit ID on the front end for the users to see. However, if one is to use a service like “Data Loader”, the 18-digit ID can be easily exported. Apart from this, there are situations when there might be a problem in seeking this value. In that case, you will need to use a Javascript to manually cover the ID. This can be done using the following steps.

  1. Create a new bookmark and give it a title of your choice. You can call it an “ID converter” for the ease of access in the future.
  2. Add this javascript below the URL.
  3. Save the bookmark and refresh your browser.
  4. Once you open the browser, open the bookmark and enter the 15-digit code from your URL.
  5. The code will give you an 18-digit-version of the same code.
javascript:(function(){
	var input=prompt('Enter 15-character ID');
	var output;
	if(input.length == 15){
		var addon="";
		 for(var block=0;block<3; block++){
		 	var loop=0;
		 	for(var position=0;position<5;position++){
		 		var current=input.charAt(block*5+position);
		 		if(current>="A" && current<="Z") loop+=1<<position;
		 	}
		 	addon+="ABCDEFGHIJKLMNOPQRSTUVWXYZ012345".charAt(loop);
		 }
		 output=(input+addon);
	}else{
		alert("Error : "+input+" isn't 15 characters ("+input.length+")");
		return;
	}
	prompt('18-character ID:',output);
})(); 

How does salesforce avoid ID duplication?

The most interesting of all arguments is how does Salesforce makes sure that the 15 digit code does not get re-used by any other users in the many years. As we know, the record ID is unique and remains the same until the entry is destroyed.  So the 15 digit case sensitive value is a great way to achieve maximum uniqueness. To understand how; let’s factor the characters we have available to work with. 

  1. Lower case alphabets (a-z) = 26 values
  2. Upper case alphabets (A-Z) = 26 values
  3. Number (0-9) = 10 values

This means we can get around 62 unique IDs if the record ID was as single-digit value. Thus, We can replicate the same calculation for a 2 digit value. This time the available unique entries will be as high as 62 times the old value, which is 3844.

In the case of Salesforce, they are using a 15 digit value. So this iteration done 15 times, will give us a number that is so big, it will definitely be bigger than the users of the platform. This way the platform is able to generate millions of unique IDs; since there is never going to be a chance that they run out of digits or need overlap or replacement.

This is the same as the logic of a mobile number. These are 10 numerical-digit numbers. The number of combinations that can be in circulation at any time has never overpowered the need for new numbers. Imagine the same situation, except we have not just 10 numerical digits but also case sensitive letters of the English language. 

What is the Ideal practice for using record IDs within Salesforce?

When we consider the use of record ID’s within the platform, there we must ALWAYS consider them to be case sensitive. The use of the additional 18 digits (or the 15 digits) is only in the case of external apps such as access or excel.

For example, we were to copy the whole database of entries into excel, the difference between capital-letter-A and small-letter-a is not taken as uniquely. This means:

Record1: 000111222XbbAAa

Record2: 000111222XbbAAA

Both the above have only one difference, but on any other platform, this will be flagged as a duplicate entry. Thus within the platform, all the IDs are considered to be case-sensitive and should always be kept in mind when manually replicating them anywhere.