Great new fix for the 15-character ID problem!

posted Sep 1, 2011, 10:56 AM by Ezra Kenigsberg   [ updated Jun 4, 2012, 10:58 AM ]

#DataTipOfTheDay 2011-09-01

Q: "How can I make 18-character record IDs show up in Reports? Without using code?"

A: Create a formula field with a name like "Opportunity ID (18 char)" that returns text. The formula should be: CASESAFEID(Id)

That's it!

If anyone's really crazy, they're welcome to check out the old formula I'd created, described below:
Id & 
MID( 
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345", 
    MIN(FIND(MID(Id, 5, 1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1) * 16 + 
    MIN(FIND(MID(Id, 4, 1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1) * 8 + 
    MIN(FIND(MID(Id, 3, 1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1) * 4 + 
    MIN(FIND(MID(Id, 2, 1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1) * 2 + 
    MIN(FIND(MID(Id, 1, 1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1) * 1 + 1, 
    1) & 
MID( 
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345", 
    MIN(FIND(MID(Id, 10, 1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1) * 16 + 
    MIN(FIND(MID(Id, 9, 1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1) * 8 + 
    MIN(FIND(MID(Id, 8, 1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1) * 4 + 
    MIN(FIND(MID(Id, 7, 1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1) * 2 + 
    MIN(FIND(MID(Id, 6, 1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1) * 1 + 1, 
    1) & 
MID( 
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345", 
    MIN(FIND(MID(Id, 15, 1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1) * 16 + 
    MIN(FIND(MID(Id, 14, 1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1) * 8 + 
    MIN(FIND(MID(Id, 13, 1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1) * 4 + 
    MIN(FIND(MID(Id, 12, 1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1) * 2 + 
    MIN(FIND(MID(Id, 11, 1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 1) * 1 + 1, 
    1)

There are a bunch of solutions out there that already do this with code (in ApexJavaJavaScriptC#, PHP, Perl, and Visual Basic), but imo, a formula's a heckuva lot easier.

Many thanks to Alan Shanahan for his terrific blog post!
Alan Shanahan's excellent picture explaining the 15-to-18-character ID process

Wishing everyone a splendid Dreamforce!
Comments