INITCAP Function in Salesforce | Initial Upper Case Formula in Salesforce

Are you facing a problem in Salesforce, where you need to manipulate the text string by changing the text to lowercase while ensuring the initial letter of each word is capitalized?

Such as you need to standardize the product name because you encountered the problem of inconsistency in the way users input them. Some users capitalize all letters, while others use all lowercase.

Additionally, there are cases where a mix of lowercase and uppercase letters exists in the product names.

If yes, there’s no need to worry, Salesforce provides us with the function named INITCAP that helps you to make your input consistent, uniform, and in the proper format.

Within this Salesforce tutorial, you will learn about the INITCAP function, and how to use the INITCAP function in Salesforce.

Additionally, you will learn the basic syntax of the function in Salesforce and see various examples illustrating several use cases of the function.

Moreover, the tutorial will guide you through the steps of creating a formula that initializes the first character to uppercase in both Salesforce Lightning and Salesforce Classic.

Salesforce INITCAP Function

The INITCAP function in Salesforce stands for “Initial Capitalized”. It is a part of the TEXT functions in Salesforce, which is used for text operations and efficient data manipulation on Salesforce fields.

The Salesforce INITCAP function transforms the text to lowercase while capitalizing the first letter of each word. This function is useful when you want to maintain consistency and proper formatting of the records you input.

In addition, the function recognizes where each word starts by looking at the white spaces or non-alphanumeric characters like formfeed, newline, carriage return, tab, or vertical tab.

Moreover, if you try to use something other than text as a parameter, you’ll get an error. The error message will be like “Incorrect parameter type for function ‘INITCAP()’. Expected Text, received other DataType”.

In simple terms, it means that the function expects the text field or the text enclosed in the quotes, but if you pass something else by mistake to the function it will not work fine.

Now that you have got the basics of the INITCAP function, let’s move to the next section and take a look at the syntax of the INITCAP function in Salesforce.

Syntax of INITCAP Function in Salesforce

It is very important to know about the syntax of any function to work properly with them. So, here is the syntax for the INITCAP function in Salesforce:

INITCAP(text)

Here:

  • text: The text is the parameter that specifies the text field or the text expression that you want to change the first letter of each word capitalized. It is the required parameter.

It is the rule of the function that it always returns something in the back. The return value of the INITCAP function is as given below:

Return: The INITCAP function returns the text where all the letters are in lowercase, but the first letter of each word is capitalized. It makes the text string neat and consistent.

Now that you have covered the syntax of the INITCAP function, let’s move to the section and see some simple examples of the function that helps you to understand how the function operates in practical situations.

Basic Use Case of INITCAP Function in Salesforce

The table given below provides examples of how the INITCAP function works in Salesforce.

The “Input Field” column shows the text expressions entered by the user, and the “Return” column displays the resulting expression returned by the INITCAP function.

Input FieldReturn (INITCAP Function)
“united states of america”United States of America
“washington, d.c.”Washington, D.C.
“usa olympics 2024”USA Olympics 2024
“new york city”New York City

Now that you have gone through examples showcasing how the INITCAP function works, let’s proceed to the next section to explore the steps on how to initialize the first character to uppercase in Salesforce Lightning with the scenario.

How to initialize the first character to uppercase in Salesforce Lightning

When working with Salesforce there may be instances where you need to initialize the first character to uppercase in Salesforce Lightning:

One such example is suppose you want to standardize the contact name to make the uniformity in the name of the contacts.

This section will guide you through the steps on how to achieve this goal by utilizing the INITCAP function in Salesforce Lightning. Here are the steps to follow:

Step-1: Access Salesforce Lightning Setup

  • Open up the Salesforce login page and enter your credentials to log in.
  • Make sure you are logged in to the Lightning Experience. If not switch from Salesforce Classic to Lightning Experience.
  • By default, every time you log in you fall on the home page. To redirect to the main setup, click on the “Gear” icon at the top-right corner of the screen.
  • From the dropdown menu, select the “Setup” option.
INITCAP Function in Salesforce

Step-2: Select Object and Create Field

  • Click on the “Object Manager” at the top navigation bar.
INITCAP Function in Salesforce Example
  • Use the “Quick Find” box to search for the object name for which you want to change the first character to uppercase and click on it.
  • For example, according to the scenario, I decided to choose the “Contact” object.
INITCAP Function in Salesforce Lightning
  • Click on the “Fields & Relationships” option in the left section.
  • Once you are on the fields & relationships page, find the “New” button at the top and click on it to create a new field.
INITCAP Function in Salesforce Lightning Example

Step-3: Choose Input and Return Field Type

  • Specify the type of information that the custom field will contain by choosing the data type from the list.
  • For the INITCAP function scenario, you need to use the “Formula” data type. Click on the radio button in front of “Formula”.
  • After that, to proceed click on the “Next” button.
Salesforce INITCAP Function
  • Enter the appropriate “Field Label”. For example, according to the scenario, you can enter “Standardized Contact Name”.
  • Click on the “Field Name” box, and it automatically fills based on the field label. No need to type here.
  • Scroll down to the “Formula Return Type” section, from the list of available types click on the radio button next to “Text” as the INITCAP returns the result as text.
  • Then click on the “Next” button to proceed.
Salesforce INITCAP Function Example

Step-4: Enter the Formula

  • You are on the advanced formula sub-tab, move to the “Functions” section.
  • Click the “All Functions Categories” dropdown and choose the appropriate category of the function. In accordance with the scenario, you need to select the “Text” category.
  • From the selected category, search and choose the “INITCAP” function by clicking on it.
  • After selecting the functions you need, click on the “Insert Selected Function” button located under the functions section.
  • Replace the parameters of the functions with the text field or text expression, as required by the scenario to create the final formula.

For example, if you want to standardize the contact name with the first character of each part of the name being capitalized and the rest of them lowercase.

INITCAP( FirstName )

Here is the detailed description of the formula:

  • The INITCAP Function is used to perform initial capitalization on text expressions or text fields and make the rest of the characters in lowercase.
  • The FirstName is the field that you want to modify. In simple terms, the firstname is the text field whose first letter for each word you want to capitalize.
  • After entering the formula, click on the “Check Syntax” button to verify the formula.
  • If the formula is error-free, you will see a success message like “No Syntax error in merge fields or function”.
  • If there are errors, review the error message to identify and correct issues in the formula.
  • Optionally, you can add a “Description” and “Help Text” to provide additional information. The help text will be displayed on detail and edit pages when users hover over the info icon next to the field.
  • Click on the “Next” button to proceed to the next step.
Salesforce Lightning INITCAP Function

Step-5: Field-Level Security

  • Select the profiles to whom you want to grant field-level security edit access for the custom formula field.
  • Some profiles may be selected by default. If you want to grant access to additional profiles, click on the checkbox next to the respective profile names.
  • You can quickly select all profiles by clicking on the checkbox next to the “Visible” option.
  • Click on the “Next” button to proceed to the next step.
Salesforce Lightning INITCAP Function Example

Step-6: Page Layout Setting

  • You will see a list of available page layouts. By default, all page layouts are usually selected.
  • Review the default selections and unselect any layouts where you do not want to include the custom formula field by clicking on the checkbox next to the layout.
  • Click on the “Save” button to save the process of creating the formula field using the INITCAP function.
Initialize first character to uppercase in Salesforce Lightning

Step-7: Testing

Once the formula field is created, you will be able to use this formula field. Let’s see an example:

  • Open the “Contacts” item, create a new contact with the field “First Name” and save the contact.
  • After saving it, move to the “Details Section” where you will see the “Satandized Contact Name” field with the output of the INITCAP function.

Let’s understand it with the example:

Suppose you have entered the contact name “john robert” and saved it. After the execution of the formula, you will get the output for the standardized contact name “John Robert”. Hence, you can say that the formula effectively changes the first character of each letter of the text string to the upper case.

Initialize first character to uppercase in Salesforce Lightning Example

With this, you have learned how to use the INITCAP function to initialize the first character to uppercase in Salesforce Lightning. Now, you will learn how to use the INITCAP function in Salesforce Classic in the next section.

How to create formula to capitalize first letter in Salesforce Classic

Within the Salesforce Classic, there are various situations where you can use the INITCAP function.

Consider a scenario where you are importing the data from an external source and you have observed that there is an inconsistency in the campaign name.

Let’s explore the steps of how to create a formula to capitalize the first letter in Salesforce Classic:

Step-1: Access Salesforce Classic Setup

  • Sign up into the Salesforce account using your credentials.
  • Once logged in check the interface on which you are right now. If you are on the Classic Interface already skip this step. Otherwise, locate the option of “Switch to the Classic Interface” in the upper right corner profile menu.
INITCAP Function in Salesforce Classic
  • To make changes and do configurations according to the requirement, you need to access the setup. Click on the “Setup” option located on the top in between your name and the help option.
INITCAP Function in Salesforce Classic Example

Step-2: Select Object and Create Field

  • Scroll down to the “Build” section located on the left side of the interface
  • Click on the “Customize” dropdown option within the build section. It will display the list of the custom and standard objects in classic.
  • Choose the specific object for which you want to create the custom field and use the INITCAP function. According to the scenario, select the “Campaigns” object from the list.
  • After selecting the object, you will get the dropdown list. From the dropdown menu click on the “Fields” option.
Salesforce Classic INITCAP Function Example
  • Now, move down to the section named “Campaign Custom Fields & Relationships”.
  • Click on the “New” button to start the process of creating a new custom field.
Example of Salesforce INITCAP Function

Step-3: Decide Input and Output Data Type

  • Choose the appropriate data type for the custom field by clicking on the radio button in front of the field name. According to the scenario, select the “Formula” data type.
  • Click on the “Next” button to move to the next step.
Salesforce Classic INITCAP Function
  • Enter the “Field Label” for the new custom formula field. For example, in the above-defined scenario, you can enter “Standardized Campaign Title”.
  • Then, the “Field Name” will automatically populate based on the field label.
  • Scroll down to the section named “Formula Return Type”. Select the appropriate data type for the formula return type by clicking on the radio button next to the desired data type.
  • For example, select the “Text” data type as specified in the scenario.
  • Then, click on the “Next” button to proceed.
Create formula to capitalize first letter in Salesforce Classic

Step-4: Create Formula

  • Define the formula based on the above-defined scenario. Move to the “Functions” section on the right side of the formula subtab.
  • Click on the “All Function Categories” dropdown and choose the category containing the required function. In accordance with the scenario, select the “Text” category as the INITCAP function is part of the text type.
  • Find and select the required function from the category. In this example as per the scenario choose the “INITCAP” function.
  • Click on the “Insert Selected Function” button below the function section to insert the chosen function in the formula.
  • Replace the parameters of the function with the appropriate text field or text expression as the function only accepts the text string, if pass anything else error will be raised.
  • For example, to ensure the consistency of the campaign name you decided to capitalize the first character of each letter of the title of the existing or new campaigns.

Below is the formula as per the example:

INITCAP(Name)

Here is a detailed description of the above-written formula:

  • INITCAP function is one of the text functions in Salesforce that is used to perform initial capitalization on the first letter of each text expression or text field that is passed to the function and makes the rest of the characters in lowercase.
  • The Name is the field that you pass to the function to manipulate the text stored in it. In another way, the campaign name is the text field whose first letter for each word you want to capitalize.
  • To check errors in the formula, click on the “Check Syntax” button and verify. If any error is found try to solve it.
  • Optionally, you can enter the “Description” and “Help Text” to give the user more information on how the formula works.
  • Click on the “Next” button to move to the next step.
Create formula to capitalize first letter in Salesforce Classic Exanple

Step-5: Customize Field Level Security

  • Select the profiles to which you want to grant edit access to this field via field-level security. The field will be hidden from all profiles if you do not add it to the field-level security.
  • By default, some profiles are already selected. If you want to change something, click on the checkboxes next to the profiles to either select or unselect them.
  • But if you want to select or unselect all the profiles to give the edit access to the field quickly, click on the “Visible” checkbox.
  • After choosing the profiles, click on the “Next” button to move to the next step.
Initial Upper Case Formula in Salesforce

Step-6: Specific Page Layout

  • Select the page layout that should include this field. The field will be added as the last field in the first 2-column sections of the page layouts.
  • The field will not appear on any pages if you do not select a layout.
  • Note that all the page layout names are pre-selected. Unselect those page layouts where the field is not required by clicking on the checkbox next to their names.
  • To add the field to the selected page layouts, click on the “Save” button and complete the step of the formula creation that capitalizes the first letter in Salesforce Classic.
Initial Upper Case Formula in Salesforce Example

Step-7: Testing

Now, you will be able to use this formula field. Let’s see the steps with example:

  • Navigate to the “Campaigns” item in Salesforce Classic.
  • Create a new campaign by clicking on the “New” button.
  • Fill in the necessary field such as “Campaign Name” with the value.
  • After entering the details click on the “Save” button to save the new campaign.
  • Click on the campaign name that you have created now, to open it and move to the Details Section.
  • Locate the “Standardize Campaign Title” on the page layout.
  • You will see the output of the INITCAP function on the standardized campaign title field based on the formula you defined.

Let’s understand it with the example:

Suppose you entered the campaign name “elevate & CELebrate: A year of acHivements”. After saving the campaign, the formula field with the INITCAP function is executed.

The output for the standardized campaign name field is “Elevate & Celebrate: A Year Of Achievements” which is the result of the INITCAP function.

Initial Upper Case Formula in Salesforce Classic

With this, you have learned how to use the INITCAP function to create a formula to capitalize the first letter in Salesforce Classic.

Conclusion

It is possible to modify the text string in such a way that the text changes to the lowercase while making the initial letter of each word capitalized.

You can use the Salesforce INITCAP function in the formula field for this because the function converts the text passed as a parameter to it to lowercase and capitalizes the first letter of each word.

Through this complete article, you have learned the syntax and use cases of the INICAP function. Additionally, you have explored the step-by-step implementation of the function in both Salesforce Lightning and Salesforce Classic.

You may like to read the following articles: