2

I run this query :

SELECT Id,Name FROM  Account where Id='0013000000Ghg4k'

it returns the value but I noticed the different of return Id.Query with '0013000000Ghg4k' and it return Id '0013000000Ghg4kAAB' It is not same except some beginning character but how it able to return the value at the first place?Any explaination on this.

Note that different Id while I expect it to be same

  • check out the article here: help.salesforce.com/apex/… – Sam Jan 16 '15 at 8:38
  • If user give me 15 characters id in Set, then I query with it and store return data inside map which 18 character as key, my map won't be searchable except if I truncate the return Id from query then store as map key.I wonder is there easy method to solve this type of issue. – unidha Jan 16 '15 at 8:59
  • Id comparison is different from string comparison. So that should not be a problem at all. A 15 char Id will be equal to its 18 char counterpart in comparison. – Sam Jan 16 '15 at 9:11
  • 1
    So instead using map<String,Account> mapAccount, it is better to use <Id,Account> ? – unidha Jan 16 '15 at 9:14
  • yes, always.... – Sam Jan 16 '15 at 9:15
7
  1. 15 digit case-sensitive version which is referenced in the UI
  2. 18 digit case-insensitive version which is referenced through the API

The last 3 digits of the 18 digit ID are a checksum of the capitalisations of the first 15 characters, this ID length was created as a workaround to legacy systems which were not compatible with case-sensitive IDs. The API will accept the 15 digit ID as input but will always return the 18 digit ID.

Here is a great answer What are Salesforce ID's composed of? if you want to know how the Id is composed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.