CASESAFEID() Function in Salesforce | Syntax, Examples, & Use Cases : Bijay Kumar
by: Bijay Kumar
blow post content copied from SalesForce FAQs
click here to view original post
### Summary of Salesforce CASESAFEID Function The content discusses the Salesforce CASESAFEID function, which is used to convert 15-character case-insensitive Salesforce IDs into 18-character case-sensitive IDs. This function is helpful because it enhances compatibility with tools like Excel and is widely usable within Salesforce, except in reports and s-controls. **Key Details:** - **Function Purpose:** Converts a 15-record ID to an 18-record ID. - **Validity Check:** In Salesforce Classic, the function checks if the ID is valid by ensuring it does not start with a capital letter. - **Registration Requirement in Lightning:** To use the function with only valid IDs in Salesforce Lightning, users must contact Salesforce support. - **Syntax:** The syntax for using the function is `CASESAFEID(id)`, where `id` can be a text field or directly input as a string. - **Steps for Implementation:** 1. Access Salesforce Lightning and open the Setup menu. 2. Navigate to the Object Manager and select the desired object (e.g., Account). 3. Create a new formula field, opting for the TEXT data type. 4. Enter the `CASESAFEID(AccountNumber)` formula in the advanced formula editor. 5. Define field-level security and add the field to the desired page layout. After creating the field, users can create or edit records to see the output of the CASESAFEID function. **Conclusion:** The CASESAFEID function is essential for working with Salesforce IDs, providing a straightforward method for enhancing ID management. ### Additional Context: Salesforce, a leading customer relationship management (CRM) platform, enables businesses to manage customer data efficiently. Functions like CASESAFEID are crucial for data integrity, especially when integrating Salesforce records with external applications. ### Suggested Hashtags for SEO: #Salesforce #CASESAFEID #SalesforceTutorial #IDConversion #CRM #DataManagement #SalesforceLightning #SalesforceClassic #SalesforceFunction #TechTutorial
Recently, I worked at a multinational company that uses Salesforce to manage customer relationships. One day, I was assigned the task of converting a 15-record ID to a case-insensitive 18-record ID.
So, I have searched a lot and found that Salesforce has a built-in function named “CASESAFEID” for these types of conversions.
In this Salesforce tutorial, we will learn how to use the CASESAFEID function. In addition, we will see the syntax of the CASESAFEID function in Salesforce, along with real-world business examples.
What is the CASESAFEID() Function in Salesforce?
In Salesforce, CASESAFEID() is one of the Salesforce text functions that are used to carry out text operations.
The CASESAFEID() function is the function used to convert the 15-character case-insensitive Salesforce ID into an 18-character case-sensitive ID.
But in Salesforce Classic, this function first checks whether the input is a valid Salesforce 15-record ID. If so, it only converts to an 18-record ID. To check its validity, it checks that the ID does not begin with a capital letter.
In addition to this, if you want the function to convert only valid 15-record IDs in Salesforce Lightning, you have to contact Salesforce customer support to activate this functionality.
Moreover, converting these 18-record IDs improves compatibility with Excel. And you can also use this CASESAFEID function everywhere in Salesforce, except the Salesforce reports and s-controls.
Syntax and Usage of CASESAFEID() Function in Salesforce
The following is the syntax of the CASESAFEID function in Salesforce:
CASESAFEID(id)
Here, id is the parameter whose value you want to replace with the case-insensitive 18-record ID. You can pass any of the text fields to the parameter, or you can directly pass the 15-record ID enclosed in the quotation marks.
Moreover, the parameter only accepts text-type data; if you pass any other type of data as a parameter, it will produce an error.
Let’s look at scenarios to understand the CASESAFEID function better.
Suppose we have a 15-record ID and we want to convert it. The formula’s evaluation produces a case-insensitive 18-record ID. Here, is the formula:
CASESAFEID("0012v00002T3vgc")
With this, we have learned the syntax of the CASESAFEID() function with an example. And now, we will proceed and learn how to use the CASESAFEID function in Salesforce Lightning.
How to Use CASESAFEID() Function in Salesforce
The following are the steps to use the CASESAFEID() Function in Salesforce Lightning:
- Open Salesforce Lightning mode. Next, click the “Gear Icon” in the top right corner of the page. Click “Setup“ from the dropdown menu to continue.

- The setup page opens when you select the Setup option. Here, the “Object Manager” is found in the Navigation Bar next to the Home tab. Click on it.

- The object manager page opens when you click it. There are numerous objects seen here. Use the Quick Find search field to find the item on which we want to use the CASESAFEID() function.
- In this instance, I look for the “Account” object because I need to convert the account ID from 15 digits to 18 digits.
- Now, click the “Account” object to move to the account object page.

- On the product object page, the “Field & Relationship“ option is in the details section on the left side. Select “Field & Relationship” from the menu.
- The field and relationships page is opened after selecting the field and relationship option. Click the “New” button at the top of the page.

- The field type page opens when you click the new button. The page contains a wide variety of field types. In this case, I chose the “Formula” field type, as I want to use the TEXT function in the advanced formula.
- Click the “Next” button to move on to the next step.

- The choose output type screen appears after clicking the next button. Enter the information now by filling out the “Field Label” and the “Field Name”, which is automatically filled in when you put the cursor on the field name. In this instance, I typed “Sensitive Account Number” into the field label.
- Choose the “Output Data Type“ for the field in which we want to store the result. In this case, I check the radio button next to the “Text” data type to return the formula result as text.
- Move to the next step by clicking the “Next” button.

- Go to the advanced formula editor and enter the CASESAFEID () function formula there. In this instance, I want to use the CASESAFEID function to convert the 15-digit record ID to 18 digits. The formula is as follows:
CASESAFEID( AccountNumber )
- Here, we use the CASESAFEID() function that converts the AccountNumber from a 15-character case-insensitive ID to an 18-character case-sensitive ID.
- Click on the “Check Syntax” button to verify that the formula has no errors.
- We can define the “Description,” “Help Text,” and “Handle the empty field” if we want.
- To go to the next step, click on the “Next” button.

- In this step, establish “Field-Level Security“. Choose the profiles to which we wish to grant field-level security edit access to this field. If field-level security is not added, the field will be hidden from all profiles.
- As I want it to be visible to all profiles, I have checked the “Visible” checkbox in this instance. After that, click the “Next” button located at the top.

- Add the custom field to the “Page Layout“ after setting up the field-level security. Pick the page layout that has this field in it. If we do not select a layout, the field will not appear on any pages.
- To save the formula field, click the “Save” button.

We can use the formula field once we have created it. Let’s look at an example:
- Open the Account Tab and create a new account with the field Account Number.
- After saving it, move to the Detail Section, where the Sensitive Account Number field displays the output of the CASESAFEID function.

With this, we have understood how to use the CASESAFEID() function in Salesforce Lightning.
Conclusion
In a nutshell, we have learned what is Salesforce CASESAFEID function with its syntax and real-world business scenarios. In addition, we have learned the steps of using the CASESAFEID function in the formula field in Salesforce Lightning and Salesforce Classic.
You may like to read:
- BR() Function in Salesforce
- BEGINS() Function in Salesforce
- CONTAINS() Function in Salesforce
- GETSESSIONID() Function in Salesforce
The post CASESAFEID() Function in Salesforce | Syntax, Examples, & Use Cases appeared first on SalesForce FAQs.
November 26, 2025 at 06:13PM
Click here for more details...
=============================
The original post is available in SalesForce FAQs by Bijay Kumar
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.
============================

Post a Comment