Salesforce IDs and the 15-18 digit problem

Posted by Brian Green on January 09, 2011
cloud, Salesforce

Salesforce CRM user?

Are you a Salesforce CRM user?  Use Microsoft Excel for analysis or reports?  Then you’ll have met the Salesforce 15 digit ID problem.

Internally Salesforce IDs are 18 digits long.  But, Salesforce Reports reduce them to 15 digits.  So, for example, an Organisation ID internally might be 0014000000LmabcAAB, but in a report it will appear as 0014000000Lmabc. The missing last three digits (the “AAB” in the example) are check-digits; used for error detection.

Now that wouldn’t be a problem if it wasn’t that Windows applications, such as Excel and Access, are case insensitive.  The 15 digit IDs are unique, which is what you need when you use the Excel function like VLOOKUP, but Excel treats 0014000000Lmabc just the same as 0014000000LMABC (case insensitive!) - so, your Salesforce IDs are no longer unique and VLOOKUP will no long find the correct match … (incidentally, the 18 digit IDs are unique to VLOOKUP!)

There are algorithms you can use to reconstruct the last three digits of your Salesforce IDs (search Salesforce Help for “How can one convert a 15 character id to a 18 character id?“), but better still there’s a script that works in Google Docs online spreadsheet.

Convert 15 to 18 Digit Salesforce IDs with Google Spreadsheets [video] – enjoy:

My thanks to David Engel, of The Engel Journal, for his Post and Video on this topic.  Similarly, David’s acknowledges in his post Damon Douglas, David Padbury, and Stefan Kuehlechner.

If you need further support processing you Salesforce data using Microsoft Excel, or Access, then please don’t hesitate contact me.  Alternatively, there’s a Java script that converts Salesforce 15 digit IDs to 18 digits that can be found here.

Share this Post:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • RSS
  • Twitter
  • Technorati
  • PDF
  • Print
  • email

Tags: , , ,

3 Comments to Salesforce IDs and the 15-18 digit problem

This post was mentioned on Twitter by Paul Milford. Paul Milford said: RT @BGConsultancy: Blog post: #Salesforce IDs and the 15-18 digit problem http://goo.gl/fb/SUYuF #salesforcecom #cloud #google #youtube [...]

Lee
January 9, 2011

Thanks for the post Brian. When I first started coding Apex for SFDC this was a major problem, in the end I wrote my own code to get around this 15-18 digit issue but this spreadsheet would have been a massive help.

Brian Green
January 9, 2011

Lee, thanks for the comment – though the coding in this case (Google Apps Script – see here) was done by bluep@quantentunnel.de

For those without access to Salesforce help, the logic is:

To convert a 15 char case-sensitive id to an 18 char case-safe id follow these steps.

1. Divide the 15 char into 3 chunks of 5 chars each
2. For each character give that position a value of 1 if uppercase, 0 otherwise (lowercase or number)
3. Combine the bits from each chunk into a 5 bit integer where the rightmost bit is the most significant bit. This will yield a number between 0 and 31 for each chunk
4. Construct an array that contains the sequence of capital letters A-Z and 0-5
5. Use the integer from each chunk to choose a character from the array
6. Append the resulting 3 characters, in chunk order, to the end of the 15 char id