[SalesForce] 15 and 18 digit in force.com database

How many I'd columns are maintained in force.com database such 15 and 18 I'd digit columns columns are maintained or only 15 digit I'd column maintained ?


15 digit I'd salesforce case sensitive = 18 digit I'd salesforce case insensitive

On importing
Internally on record creation 15 digit gets generated

On exporting
15 id is converted to 18 digit id //as salesforce written algorithm to convert 15 to 18 digit id

On updating

Generally we update the records after exporting the records

Bulk updating
As we update the record based on the record IDs which we get on export operation

On export we get 18 digit
Now based on 18 digit I'd we update the 15 digit? This is possible with two cases

  1. there should be algorithm for converting 18 to 15 id
  2. separately 18 digit Id column should be maintained in the same table

How many Id columns are maintained in force.com database? Either only 15 digit id or both 15 and 18 digit id .

In my case if only 15 digit I'd is maintained? My first possible is correct but I don't find the algorithm to convert 18 to 15 convertion .

Is there any algorithm to convert 18 to 15 digit?

Best Answer

If you have the 18 digit Id and want to get the 15 digit Id, simply remove the final three characters.

I recommend you read through this Knowledge Article:

Unique Record IDs in Salesforce

Description

Every Record, regardless of entity type, has a globally unique identification value in its ID field which is generated at the time of record creation. That Record ID value will never change, even if the record is deleted and then undeleted.

The URL of a record viewed within Salesforce via web browser contains the Salesforce instance and the Record ID.

For example: http://na1.salesforce.com/5003000000D8cuI

Record ID: 5003000000D8cuI
Instance: na1

Record ID format returned via API

Note: API access requires Enterprise Edition or Unlimited Edition.

API versions prior to 2.0

The ID of a record is always 15-characters and case-sensitive. It should not be compared in a case-insensitive manner.

API versions 2.0 and higher

The API can return either a case-sensitive or a case-insensitive ID field value. The case-insensitive ID is identical to the 15-character case-sensitive ID, but with 3 extra characters appended to indicate the casing of each of the original 15 characters.

When inserting or updating records, the API accepts either the 15-character case-sensitive ID or the 18-character case-insensitive ID.

When querying or searching records using the API, you must specify a value of "1" for the "useCaseSafeIDs" parameter to indicate that you want the API to return case-insensitive IDs. If you don't specify the "useCaseSafeIDs" parameter, you automatically receive case-sensitive IDs.

API version 2.5

The API defaults to 18 characters on the ID (case-insensitive) and provides no option to use the 15-character case-sensitive ID explicitly. The "Reports" tool queries the database directly and therefore returns a 15-character case-sensitive ID. Tools like the Data Loader, Demand Tools, or the Weekly Data Export service will export records with the 18-character ID.

Additional from the API Developer's Guide

You'll find this info under 'Field Types - ID Field Type.'

  • ID fields in the Salesforce user interface contain 15-character, base-62, case-sensitive strings. Each of the 15 characters can be a numeric digit (0-9), a lowercase letter (a-z), or an uppercase letter (A-Z). Two unique IDs may only be different by a change in case.
  • Because there are applications like Access which do not recognize that 50130000000014c is a different ID from 50130000000014C, an 18-digit, case-safe version of the ID is returned by all API calls. The 18 character IDs have been formed by adding a suffix to each ID in the Force.com API. 18-character IDs can be safely compared for uniqueness by case-insensitive applications, and can be used in all API calls when creating, editing, or deleting data.
  • If you need to convert the 18-character ID to a 15-character version, truncate the last three characters. Salesforce recommends that you use the 18-character ID.

18-character Record IDs are just case-insensitive. For example, if you fire a SOQL query for Record ID "00330000000xEftMGH" and "00330000000xEftmgh," the latter will return no results. This means that they are case-sensitive in Salesforce. When used with tools like Excel or Access, you can devise methods to produce case-insensitive IDs.

Related Topic