Skip to content. | Skip to navigation

Personal tools
Log in
Sections
You are here: Home Database Salesforce Planning & Configuration Converting IDs from 15 to 18 Characters

Converting IDs from 15 to 18 Characters

What a party trick!

When a user pulls information containing the id from the API, the id contains 18 characters. On the other hand, if the user looks at the id in the Reports tab or the Weekly Export Service, the id will only contain 15 characters. This is done intentionally to provide case-sensitive and case-insensitive versions of the same globally unique id. There may be some cases where a conversion needs to be done. Here is information on how to convert id numbers from 15 to 18 characters.

All case-sensitive ids are 15 chars. 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.

Example:
Convert 500x000000003TR to 18 character ID


|---------|---------|---------|
chunks | chunk 1 | chunk 2 | chunk 3 |
|---------|---------|---------|
chunk index |1|2|3|4|5|1|2|3|4|5|1|2|3|4|5|
|---------|---------|---------|
id string |5|0|0|x|0|0|0|0|0|0|0|0|3|T|R|
|---------|---------|---------|
string bits |0|0|0|0|0|0|0|0|0|0|0|0|0|1|1|
|---------|---------|---------|

|---------|
chunk index |5|4|3|2|1|
|---------|
chunk 1 bits = |0|0|0|0|0|
|---------|

|---------|
chunk index |5|4|3|2|1|
|---------|
chunk 2 bits = |0|0|0|0|0|
|---------|

|---------|
chunk index |5|4|3|2|1|
|---------|
chunk 3 bits = |1|1|0|0|0|
|---------|

chunk 1 index = 0 = A
chunk 2 index = 0 = A
chunk 3 index = 24 = Y

Resulting ID: 500x000000003TRAAY

Bit to integer to character map
From right to left

|--------------|
|Bits |int|char|
|--------------|
|00000| 0 | A |
|--------------|
|00001| 1 | B |
|--------------|
|00010| 2 | C |
|--------------|
|00011| 3 | D |
|--------------|
|00100| 4 | E |
|--------------|
|00101| 5 | F |
|--------------|
|00110| 6 | G |
|--------------|
|00111| 7 | H |
|--------------|
|01000| 8 | I |
|--------------|
|01001| 9 | J |
|--------------|
|01010| 10 | K |
|--------------|
|01011| 11 | L |
|--------------|
|01100| 12 | M |
|--------------|
|01101| 13 | N |
|--------------|
|01110| 14 | O |
|--------------|
|01111| 15 | P |
|--------------|
|10000| 16 | Q |
|--------------|
|10001| 17 | R |
|--------------|
|10010| 18 | S |
|--------------|
|10011| 19 | T |
|--------------|
|10100| 20 | U |
|--------------|
|10101| 21 | V |
|--------------|
|10110| 22 | W |
|--------------|
|10111| 23 | X |
|--------------|
|11000| 24 | Y |
|--------------|
|11001| 25 | Z |
|--------------|
|11010| 26 | 0 |
|--------------|
|11011| 27 | 1 |
|--------------|
|11100| 28 | 2 |
|--------------|
|11101| 29 | 3 |
|--------------|
|11110| 30 | 4 |
|--------------|
|11111| 31 | 5 |
|--------------|
Document Actions

Comments (0)

« February 2012 »
February
MoTuWeThFrSaSu
12345
6789101112
13141516171819
20212223242526
272829