Salesforce Record Id

 Record Id is used to identify the record uniquely in a Salesforce Org. There are 2 types of record Id in Salesforce:

  1. 15 digit
  2. 18 digit
15-digit record Id is case-sensitive where as 18-digit record Id is case-insensitive

15-digit record Id is referenced in UI and also visible in browser. It is true in classic but in lightning 18 digit record Id is being used in UI and also visible in browser.

18-digit record Id is referenced through the API. The last 3 digit of the 18-digit record Id is a check sum of the capitalization of the first 15 characters.

A 15-digit record Id can be converted into 18-digit record Id using CASESAFEID() function. To convert 18-digit record Id into 15-digit record Id, simply remove last 3 digits from 18-digit record Id.

Why we need 18-digit record Id when there was 15-digit record Id: Apex is a case-insensitive language. As 15 digit record Id is case-sensitive therefore we can not use it directly in Apex code. Therefore earlier in classic we were converting the 15-digit record Id into 18-digit record Id using CASESAFEID() function to make it case-insensitive so we can use it in Apex. Now in lightning, Salesforce is already using 18-digit record Id in UI as well as in browser therefore we need not to do anything before using it Apex.


Comments

Popular posts from this blog

Difference between var, let and const keyword in JavaScript

Salesforce External ID