What is difference between 15 and 18 Digit Record Id’s in Salesforce?

Many time during my mentoring sessions I get asked by new administrators and developers this question. “What is the difference between a 15 digit id and 18 digit id in Salesforce?”

Normally, when a Salesforce user pulls the id from a record through the interface on any object they get the 15 digit id by design.  So, if you created a report on Leads / Account / Contacts or any custom object and add the id field through the interface it will look something like 0015000001Fn4VL.

However, if you were to access that same Salesforce account id via an API or a tool like this from the Apex Dataloader & workbench 0015000001Fn4VLAAZ.

One thing to note is that Salesforce IDs are case sensitive when they are 15 digit and insensitive when they are 18 digit.  This means you must take into account upper and lower cases when you export the data from the system for the case sensitive data elements.  If your using tools like vlookup in Excel to do comparison from various sources of data, be careful as Excel can incorrectly map the data since it is not case sensitive on the 15 digit id.

The last three digits in the ID is a checksum.  A calculation to assure that the first 15 pieces of the ID are accurate for the object its being written into.

So following that analogy just mentioned.

15 digit case-sensitive version

15 digit ID is what will be received from within the user interface

18 digit case-insensitive and best used for manipulating data outside Salesforce

18 digit id is referenced through in the API and other 3rd party tools.

If you would like to convert the current user interface id to 18 digits this can be done by using a formula very simple formula.  I have seen a couple of versions of the formula but this is the one that worked best for me in my career.

All you need to do is add a new formula field, text 18 characters with “CASESAFEID(ID)”

Salesforce has a knowledge base article on this topic which gives clear instructions on how to use it.

Convert a 15 character ID to a 18 character ID

Salesforce

Knowledge Article Number

000005288
Description Convert 15 character IDs to 18 character IDs to update records,

or to make working in systems that aren’t case sensitive easier.

Resolution Follow the steps below to create a formula field that will give you

the 18 characters ID of the records.

1. Go to Setup | Customize | object name | click Fields
– For Custom objects: Setup Create Objects | object name
3. In the related list “Custom Fields & Relationships” click New.
4. Click the Formula radio button.
5. Click the Text radio button for “Formula Return Type.”
6. Input the following Formula into the Formula Editor:

CASESAFEID(Id)

7. Set Field Visibility, add/ remove from Page Layout(s).
8. Click Save.

So when your boss asks you to do that dataload of leads / Accounts / Contacts or Opportunities rise up and take the challenge.  Using the formula will help you access the 18 digit Id so you can successfully cleanse the data outside the system and push it back up after the business has fixed the incorrect data elements.