How to Get 18 Digit Salesforce Id in Report

As a Salesforce system administrator, I recently created a custom report to pull out the IDs of account and contact records from our Salesforce org, but there was an issue fetching the IDs of the records. The IDs of records are generally 18 digits, but the report data only gave 15-digit IDs of records.

As a solution, I created a custom formula field in the objects, from which I have to get the 18-digit IDs using the CASESAFEID() function.

In this Salesforce tutorial, I will explain how to create a formula field to convert a 15-digit ID to an 18-digit one. Then, with that, you can get an 18-digit ID in the Salesforce report.

Get 18 Digit Salesforce ID of Object Records in Report

To obtain the 18-digit Salesforce ID of Object Records in the report, we must first create a formula field for the object to display the record’s 18-digit ID.

After this, we will use this custom field in the report to display the 18-digit ID of the object record.

Create a Formula Field to Get 18-character ID of Records

To create a formula field for the 18-character ID of records in Lightning, navigate to the setup page of Salesforce and follow the steps below.

  1. On the setup page, click on the Object Manager tab. In the next window, select the account object (or the object for which you need to fetch the ID).
Get 18 digit Id in Salesforce Reports
  1. In the account object, click Fields and Relationships, then click the New button in the next window.
Convert a 15 digit record id to 18 digit in Salesforce
  1. In this step, select the option Formula from the list of datatypes and click Next.
Convert a 15-character Id to an 18-character Id in Salesforce
  1. In this step, enter the field label for the formula field. Then, in the Formula Return Type, select Text and click on the Next button.
How to get full 18 character Salesforce ID in reports
  1. In the formula editor, enter the formula below and click the Next button.
CASESAFEID(Id)
How to get 18 digit ID in formula field Salesforce
  1. Select the visibility for the formula field, and select the profiles to make the field visible for the profiles. The field will be visible for the profiles selected from the Visible column.

After selecting the profiles, click on the Next button.

Convert a 15-character Id to an 18-character Id in Salesforce lightning
  1. In this step, we must select the field’s visibility on the object’s page layouts. In this case, we have created the formula field for the reports so we can choose not to display it on the page layouts.

Uncheck the checkboxes of the page layouts so as not to display the field on the page layouts. After this, click on the Save button.

How to view 18 characters long Salesforce ID in reports

We have now created the formula field that will return the 18-digit ID of the records in the reports.

Create Report with the 18-digit ID of the Object Record

After creating the above formula field, we will move to the part where we will create a report with the 18-digit ID of the object record. In this example, we will create a report for the account object.

  1. Navigate to the Reports tab, then click the New Report button.
  1. Select the Category and Report type for the report, then click on the Start Report button.
  1. In the report table, apply the required filter to generate the records. To get the 18-digit ID, we will add the formula field we created earlier.
    • To add the formula field, search the Columns section and select the created formula field.
    • I have added the Account ID and custom fields to display an 18-digit ID. Here, the custom field shows the account records in 18-digit form.
Get a report with 18 digit id of Object records
  1. After this, save and run the report.
Display 18-digit record id in a Salesforce report

The report will run in the next window, displaying the code’s 18-digit ID. Now, we can export the report and use the full ID to update, then import the account records with tools like data import wizard and data loader.

How to Get 18 Digit Salesforce Id in Report

This way, we can create a report with an 18-digit Salesforce ID of the object records in Salesforce Lightning.

Get 18-digit Salesforce Id Using Salesforce Data Loader

If we use tools like Data Loader to export the object record along with the ID field, it will, by default, give the ID field an 18-digit number.

To get the 18-digit object record ID with the data loader, install it on your system and follow the steps below.

  1. Open the data loader tool, log in with your credentials, and click the Export button.
Get 18 digit Id of Object records in Salesforce
  1. In this step, select the object, choose the location of the extracted file, and click the Next button.
How to export records with 18 digit id in Salesforce
  1. Select the query fields, such as Account NameAccount Owner, and Account ID, and click the Finish button.
Salesforce lightning export records with 18 digit ID
  1. A warning message about the data export operation will appear on the screen. Click the Yes button to proceed.
Create a report with 18 digit id of records in Salesforce
  1. After completing the data export operation, you will see the message of successful data export. Here, click the View Extraction button.

In the extracted data, you will see that the object’s record ID is exported in an 18-digit number.

Get account and contact id with 18 digits in Salesforce reports

This way, you can use the Salesforce data loader to get an 18-digit record ID for object records in Salesforce Lightning.

Conclusion

In this Salesforce tutorial, we learned how to get and display the 18-digit record ID of the records. In this method, we first created a custom formula field in the object that fetches and displays the 18-digit code using the built-in function CASESAFEID(). Then, we used that field in the report table to display the 18-digit record IDs in the field column.

We also discussed a second way to get the 18-digit record using the Salesforce data loader tool, which can be exported in the same way we export the reports.

You may also like to read:

Agentforce in Salesforce

DOWNLOAD FREE AGENTFORCE EBOOK

Start with AgentForce in Salesforce. Create your first agent and deploy to your Salesforce Org.

Salesforce flows complete guide

FREE SALESFORCE FLOW EBOOK

Learn how to work with flows in Salesforce with 5 different real time examples.