Loading

Convert a Salesforce 15-Character Record ID to an 18-Character ID

Publiceringsdatum: Jul 16, 2026
Beskrivning

In Salesforce, record IDs can be either 15 characters (case-sensitive) or 18 characters (case-safe). Converting a 15-character ID to an 18-character ID is useful when updating records in external systems that are not case-sensitive, or when working with tools like Data Loader or the Weekly Data Export service. API versions after 2.5 use the 18-character format exclusively. Reports query the database directly and return a 15-character ID.

Lösning

There are two ways to convert a 15-character Salesforce record ID to an 18-character case-safe ID: creating a CASESAFEID formula field on the object, or using a JavaScript bookmarklet in your browser for on-demand conversions.

Option 1: Create a CASESAFEID Formula Field

This option creates a permanent formula field on an object that always displays the 18-character ID for every record. This is the recommended approach for ongoing use.

Salesforce Classic

  1. Go to Setup | Customize | object name | click Fields.
    • For Custom objects: Setup | Create | Objects | object name
  2. In the related list "Custom Fields & Relationships," click New.
  3. Click the Formula radio button.
  4. Click the Text radio button for 'Formula Return Type.'
  5. Input the following formula into the Formula Editor: `CASESAFEID(Id)`
  6. Set Field Visibility, add, or remove from the page layout.
  7. Click Save.

Lightning Experience

  1. Go to Setup | Object Manager | Object name | Fields & Relationships.
  2. Click New.
  3. Click the Formula radio button and click Next.
  4. Click the Text radio button for 'Formula Return Type.'
  5. Input the following formula into the Formula Editor: `CASESAFEID(Id)`
  6. Set Field Visibility, add, or remove from the page layout.
  7. Click Save.

Note: When dealing with record types, only custom record types have IDs. Please review Set Record Type Preferences for more information.

Option 2: Use a JavaScript Browser Bookmarklet

This option uses a JavaScript bookmarklet saved in your browser to convert any 15-character Salesforce ID to an 18-character ID on demand — without needing to create a formula field. This is useful for one-off conversions.

Set Up the Bookmarklet

  1. Create a new bookmark in your browser.
  2. Name it something memorable (like "Salesforce ID Converter").
  3. Paste the JavaScript code below into the URL field of the bookmark.
  4. Save the bookmark.

[IMAGE GOES HERE — alt: "Browser bookmark creation dialog showing the JavaScript bookmarklet code pasted into the URL field of a new bookmark named Salesforce ID Converter"]

The following JavaScript code prompts you to enter a 15-character Salesforce ID and returns the corresponding 18-character case-safe ID. Paste the entire block into the bookmark URL field:

javascript:(function(){
var input=prompt('Enter 15-character ID');
var output;
	if(input.length == 15){
		var addon="";
		for(var block=0;block<3; block++)
		{
			var loop=0;
			for(var position=0;position<5;position++){
				var current=input.charAt(block*5+position);
				if(current>="A" && current<="Z")
					loop+=1<<position;
			}
			addon+="ABCDEFGHIJKLMNOPQRSTUVWXYZ012345".charAt(loop);
		}
		output=(input+addon);
	}
	else{
		alert("Error : "+input+" isn't 15 characters ("+input.length+")");
		return;
	}
prompt('18-character ID:',output);
})();

Note: This bookmarklet may not work in the Microsoft Edge browser.

Use the Bookmarklet 

  1. Click the bookmark in your browser.
  2. Enter the 15-character ID and click OK.
  3. Copy the resulting 18-character ID from the prompt.

 

How-to Video: How to Convert a 15-Character Id to an 18-Character Id

Knowledge-artikelnummer

000385066

 
Laddar
Salesforce Help | Article