- Home
- Technical Library
- Boards
- Cookbook
- Code Share
- Blogs
- Partners
-
More
-
Services
- Training & Certification
- Support
-
Galleries
- Force.com Sites Gallery
- Chatter Challenge Entries
-
Other Web Sites
- Salesforce.com
- Database.com
- AppExchange
- CRM Community
-
Discussions
- Announcements
- General Development
- Schema Development
- New to Cloud Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules Discussion
- Security
- Mobile
- Force.com Sites
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby Development
- Adobe Flash Builder for Force.com
- Desktop Integration
- REST API Integration
- Streaming API
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- Excel Connector
- AJAX Toolkit & S-controls
- Force.com Builder & Native Apps
- AppExchange Directory & Packaging
- Force.com Labs Projects
- Open Source
- Site.com
- Jobs Board - Administrators
- Jobs Board - Developers
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- General Development
- :
- Re: GetUserInfoResult.getOrganizationId does not e...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
GetUserInf oResult.ge tOrganizat ionId does not equal OrgID
[ Edited ]
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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?
Solved! Go to Solution.
Re: GetUserInf oResult.ge tOrganizat ionId does not equal OrgID
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-24-2009 05:06 PM
CVJ,
Thanks for the reply. Are the 18 character IDs new, or is this something I just hadn't run into previously?
Re: GetUserInf oResult.ge tOrganizat ionId does not equal OrgID
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-21-2010 03:04 AM
Convert 18 digit Salesforce IDs in Google Spreadshee ts with David Padbury's Script
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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.

