Skip to main content
Skip table of contents

How to Convert 15-character Salesforce IDs to 18-character IDs

Add-on:

Classic Connector for Salesforce & Jira

Question:

How to Convert 15-character Salesforce IDs to 18-character IDs

Answer:

  1. Create a Google Spreadsheet.

  2. Go to Tools > Script editor...

  3. Create a Blank Project

  4. Copy and paste the code provided in the document into the editor

    function SFConvert18(value) {
        if (value.length == 15){
            var convertedID = "";
            for (var i = 0; i < 3; i++){
                var baseTwo=0;
                for (var j = 0; j < 5; j++){
                    var character = value.charAt(i*5+j);
                    if(character >= "A" && character<="Z"){
                        baseTwo+=1<<j;
                    }              
                }
                convertedID+="ABCDEFGHIJKLMNOPQRSTUVWXYZ012345".charAt(baseTwo);
            }
            return value + convertedID;
        }
        else{
            return "Error: Please enter a valid Salesforce ID with 15 characters";
        }
    }
    function SFConvert15(value){
        if (value.length == 18){
            return value.substring(0, 15);
        }
        else{
            return "Error: Please enter a valid Salesforce ID with 18 characters";
        }
    }
  5. Save and rename the project

How do I convert a 15-character Salesforce ID to an 18-character ID?

Type the function as in the following screenshot, then select the ID you want to convert. You may also select multiple IDs for conversion.

How do I convert an 18-character Salesforce ID to a 15-character ID?

Type the function as in the following screenshot, then select the ID you want to convert. You may also select multiple IDs for conversion.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.