GetUserInf oResult.ge tOrganizat ionId does not equal OrgID
[ Edited ]
06-24-2009 04:34 PM - last edited on 06-24-2009 04:36 PM
I'm using the partner.wsdl to make a soap request from Java to the API to get information about a user based on their session id. One of the things I'm retrieving is an Org ID to make sure its within a known and trusted set. Just recently it seems that something may have changed with what is returned from the getOrganizationId() call. The value returned no longer seems to match the Org ID listed in Salesforce.com under Setup > Company Information. I am now seeing 3 characters appended to the valid org id string; EA0 in one case and EA2 in another. Has anyone else seen this?
Re: GetUserInf oResult.ge tOrganizat ionId does not equal OrgID
06-24-2009 04:39 PM
Salesforce.com Record Ids can be either 15 characters (case sensitive) or 18 characters (case insensitive). You can remove the last 3 characters if you are trying to compare an 18 character org id to a 15 character org id assuming you are also comparing the case of the characters in the id.
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.
Re: GetUserInf oResult.ge tOrganizat ionId does not equal OrgID
10-22-2009 06:57 AM
I've just had to implement the logic for converting 15 char to 18 char identifiers as described by cvj in JavaScript. I thought i'd post it here in case anyone else happens to find this useful...
function convertToCaseInsensitiveId(id) {
var hash = '';
for (var c = 0; c < 3; c++) {
var h = 0;
for (var i = 0; i < 5; i++) {
var ch = id.charCodeAt(i + c * 5);
if (ch >= 65 && ch <= 91) h += Math.pow(2, i);
}
hash += String.fromCharCode(h > 26 ? h + 48 - 26 : h + 65);
}
return id + hash;
}
Re: GetUserInf oResult.ge tOrganizat ionId does not equal OrgID
01-21-2010 03:04 AM
Convert 18 digit Salesforce IDs in Google Spreadshee ts with David Padbury's Script
06-11-2010 05:15 PM
David's Javascript is very useful because you can port that over to a Google Spreadsheet and use it like a "macro."
- Open a Google Spreadsheet
- Select Tools > Scripts > Script Editor
- Paste David's function
- Save and exit the Google Apps Script Window
- Go back to the spreadsheet. Type a 15 digit salesforce ID in Cell A2
- In another spreadsheet cell, type = convertToCaseInsensitiveId(A2)
Updated David_Padb ury Script
06-13-2010 05:38 PM
A programmer named Stefan Kuehlechner made two updates to the David Padbury script (in bold).
function convertToCaseInsensitiveId(id) {
var hash = '';
for (var c = 0; c < 3; c++) {
var h = 0;
for (var i = 0; i < 5; i++) {
var ch = id.charCodeAt(i + c * 5);
if (ch >= 65 && ch < 91) h += Math.pow(2, i);
}
hash += String.fromCharCode(h > 25 ? h + 48 - 26 : h + 65);
}
return id + hash;
}
Google Spreadshee ts CONVERT 18 Digit Salesforce IDs
07-05-2010 08:43 PM
I hired a programmer to write the david_padburry script as a free, open source Google Spreadsheet script that is much easier to implement.
Here is an article that describes how to install and use the 15 to 18 digit Salesforce ID Converter from the open source Google Spreadsheet Script Gallery.
