Salesforce Formula for Text Field

In this Salesforce tutorial, we will learn how to create a formula text field in Salesforce. Let us discuss this topic with the help of an example, Let’s suppose there is a company TechGear that is based in the United States of America this is a retail company and I am working in this company as an employee.

This company sells a variety of different products and we can use Salesforce which helps in managing and controlling our product index. In this company, every product that has a unique Stock Keeping Unit that follows a particular format like SKU-2345-010 for the first product, and then follows the same pattern for all the other products.

Here we are using the formula for the text field to create these different products. We choose the object and then select the formula field and after that select the text field and add the field name and after that enter the formula for generating the particular format for every product that has stock keeping unit.

If you want to learn the process of how to create the formula for text field in Salesforce you have come to the right place and we learn this topic in both the editions of Salesforce Lightning and Salesforce Classic.

How to create a formula for text field in Salesforce Lightning

Here we will learn how to create the formula for the text field in Salesforce Lightning. For example, Imagine I am working in a company that sells product online and all the employee of the company uses Salesforce for managing our customer data.

In this company, we have the customer object for which we are using a salesforce called order that can trace the customer order within that object. And within this customer order object, we can create the text formula field which can combine the customer’s first name and last name into a single full name.

For this, we use the formula field and then choose the text field and enter the formula inside the field.

If you want to learn how to create a formula for text field in Salesforce Lightning, follow these steps:

Step-1: First Login into the Salesforce account and we login into the Salesforce account by entering the username and password. When we log in into the Salesforce account our Salesforce Lightning version is open. Here we can create a formula for text field in Salesforce.

So for this click on the gear icon that is present at the top right corner. Under this gear icon, we can see that two options are present, the first one is setup and the other one is Service Setup. Here we are clicking on the Setup option.

The Setup page is open, under this setup page we can see that two tabs are present on the nav bar. Here we are selecting the object manager tab for choosing the object.

How to create a formula for text field in Salesforce

Step-2: After clicking on the Object Manager tab, The Object Manager page opens. Under this object manager tab, lots of objects are present.

Select one of the objects from the lots of objects If the object is not shown you want to choose to enter the object name in the search box and this search box is present at the top right corner of the page.

And here we are entering the order in the search box. The order object is already present at the first number, if the object is not present at the top after searching the object comes at the top we search in the search box, and select the order object from the object manager page.

How to create a formula for text field in Salesforce Lightning

Step-3:  The order object page is open, After clicking on the order object, under this page, we can see the details related to the object. And on the left side of the order object page, we can see the Fields and Relationships option. Click on the Fields and Relationship option.

Create a formula for text field in Salesforce

Step-4: The Fields and Relationships page is open, After clicking on the Fields and Relationships option. Under this page, we can see that lots of fields are already created. But we want to create a new field, so we click on the new button.

Create a formula for text field in Salesforce Lightning

Step-5: After clicking on the new button,  the data type page opens. There are lots of data types present on the page. Here we are selecting the formula data type field that is present at the bottom of the page. The formula field type is the read-only field that derives its value from a formula expression we define. The formula field is updated when any of the source fields change and then click on the next button.

Salesforce create a formula field type

Step-6: After selecting the formula dat type, the order new custom field page is open. Under this page firstly enter the field label here we are filling the field label as Full Name after that fill the field name which is automatically fielded by simply clicking on the field name and then auto add to the custom report type and select this checkbox.

Salesforce Lightning create a formula for text field

Step-7: After entering the field label and field name, choose the out type here we are choosing the text field that creates a text string, for example, by concatenation another text field. Click on the next button and the next button is present at the top and the bottom of the page.

How to create formula for text field in Salesforce

Step-8: After selecting the text field enter the formula click the check syntax to check for errors and click on the advanced formula subtab to use additional fields, operators, and functions. Here we are entering the formula as First Name, & operator, Last Name.

Here we use the & operator to concatenate or combine the values of the First Name and Last Name in that field with a space in between. The double quotes are used to represent space as text.

After entering the formula full name field will automatically generate the full name by simply combining the values of the First name and Last Name fields whenever the record is created. After entering the formula click on the next button.

How to create formula for text field in Salesforce Lightning

Step-9: The next step is to establish field-level security, After clicking on the next button. Here we select the profile to which we want to grant edit access to this field via field-level security. The field will be hidden from all the profiles if we do not add it to field-level security.

Here we want to select all the field-level security for the profile so we click on the visible checkbox all the checkboxes are checked and then click on the next button.

Create formula for text field in Salesforce

Step-10:

  • Here the new custom field was added to the page layouts, After checking the field-level security. Here select the page layouts that should include their fields. The field will be added as the last field in the first two-column section of these page layouts. The field will not appear on any pages if we do not select a layout.
  • To change the location of this field on the page, we will need to customize the page layout.
  • When we finish, click on the save and new button to create more custom fields, or click on the save button if we are done.
  • After clicking on the save button, the lead field and relationships page are open. Under this page, lots of fields are already created and the field we created is present inside this fields and relationships page.
  • Now go to the App Launcher, click on the app launcher, and enter the sales in the search box. The sales come at the top, click on the sales option. After clicking on the Sales, the Sales page is open. Under this Sales page, there are lots of objects present on the nav bar and we are selecting one of the objects. Here we are selecting the order object.
  • After clicking on the order object, the order page is opened. Under this page, the record is saved. Here we want to create a new order, To create the new order record click on the new button that is present in the right top corner. After clicking on the new button, the new order dialogue box is open. Here we can fill the information related to the order.
  • First, fill the first name and after that fill the last name and then fill the other information related to the order and after that click on the save button.
  • After saving the record information of the order object. The record is created and shown under the order record page. Click on the record there are two tabs present, the first one is the related and detail tab. Click on the detail tab and under this tab the related information of the order is present and we can see the first name, last name, and full name. The full name field is the combination of the first name and the last name. This can be generated due to the formula text data type.
Create formula for text field in Salesforce Lightning

In this way, we understand how to change the formula for text field in Salesforce Lightning. Let’s Proceed further and learn how to create the formula for the text field in Salesforce Classic.

How to create a formula for text field in Salesforce Classic

Here we will learn how to create a formula for the text field in Salesforce Classic. Let us take an example related to the contact object through which we can easily understand the scenario.

let us suppose we have a First Name field and a Last Name field of contact but we want a full name field in which both the first name and the last name field combine for this we create a custom formula field that automatically concatenates the first name and last name field into the full name field by simply selecting the formula data type and enter the field label and field name and then choose the text field type.

If you want to learn how to create a formula for the text field in Salesforce Classic follow these steps:

Step-1: After entering the credentials of the Salesforce account, we log into the Salesforce account, we directly log into the Salesforce Lightning account but we want to work into the Salesforce Classic account for this we want to move to Salesforce Classic.

To switch to Salesforce Classic click on the profile picture, The Profile picture drop-down menu is open, under this drop-down menu, there is an option to switch to the Salesforce Classic edition. Click on the switch to the Salesforce Classic edition. Our Salesforce Classic org is open.

Here we can see that the username is present. Click on the drop-down arrow of the username. After clicking on the drop-down arrow the drop-down list is open. Under this drop-down list, we can see that the Setup option is present. Select the Setup option.

How to create a formula for text field in Salesforce Classic

Step-2: The setup page is open, After clicking on the setup option. Enter the contacts object in the Quick Find Box. The contacts object comes at the top, click on the drop-down arrow of the contact object. Under this drop-down list, there are field options. Click on the Fields.

Create a formula for text field in Salesforce Classic

Step-3: The contact page is open, After clicking on the contact object. Now scroll to the bottom of the contact page, There are fields and relationship options present click on this field and relationship option.

The field and relationship page is open, After clicking on the field and relation option. To create the new text field and set the default value for the field, click on the new option that is present at the top of the contact custom fields and relationship section.

Salesforce Classic create a formula for text field

Step-4: The data type page opens, After clicking on the new button. There are lots of data types present on the page. Here we are selecting the formula data type field that is present at the bottom of the page. 

The formula field type is the read-only field that derives its value from a formula expression we define. The formula field is updated when any of the source fields change and then click on the next button.

How to create formula for text field in Salesforce Classic

Step-5: The contact new custom field page is open, After selecting the formula dat type. Under this page firstly enter the field label.

Here we are filling the field label as Full Name after that fill the field name which is automatically fielded by simply clicking on the field name and then auto add to the custom report type and select this checkbox.

Create formula for text field in Salesforce Classic

Step-6: Now choose the output type, After entering the field label and field name. Here we are choosing the text field that creates a text string.

For example, by concatenation another text field. Click on the next button and the next button is present at the top and the bottom of the page.

Salesforce Classic create formula for text field

Step-7:

Enter the formula click the check syntax to check for errors, After selecting the text field and click on the advanced formula subtab to use additional fields, operators, and functions.

Here we are entering the formula as First Name, & operator, Last Name. Here we use the & operator to concatenate or combine the values of the First Name and Last Name in that field with a space in between.

The double quotes are used to represent space as text. After entering the formula full name field will automatically generate the full name by simply combining the values of the First name and Last Name fields whenever the record is created. After entering the formula click on the next button.

How to create the formula for text field in Salesforce Classic

Step-8: After clicking on the next button, The next step is to establish field-level security. Here we select the profile to which we want to grant edit access to this field via field-level security. The field will be hidden from all the profiles if we do not add it to field-level security.

Here we want to select all the field-level security for the profile so we click on the visible checkbox all the checkboxes are checked and then click on the next button.

Create the formula for text field in Salesforce Classic

Step-9:

Here the new custom field was added to the page layouts, After checking the field-level security. Here select the page layouts that should include their fields.

The field will be added as the last field in the first two-column section of these page layouts. The field will not appear on any pages if we do not select a layout. To change the location of this field on the page, we will need to customize the page layout.

When we finish, click on the save and new button to create more custom fields, or click on the save button if we are done.

Salesforce Classic create the formula for text field

Step-10: The lead field and relationships page are open, After clicking on the save button. Under this page, lots of fields are already created and the field Full Name we created is present inside this fields and relationships page.

How to create an formula for text field in Salesforce Classic

Step-11: After creating the field, come back to the Home page by clicking on the Home tab. The home page is open, under this home page there are lots of objects present on the nav bar. Select the Contact object.

After clicking on the contact object, the contact page is opened. Under this page, the record is saved. Here we want to create a new contact, To create the new contact record click on the new button that is present in the right top corner. After clicking on the new button, the new order dialogue box is open. Here we can fill the information related to the contact.

First, fill the first name and after that fill the last name and then fill the other information related to the order and after that click on the save button.

Our Mrs Liza Klocko record page is open, there are two sections of record and details. Click on the details section. Under this detail section, all the information related to the contact record is present and here we can see that the full name field is automatically generated and this full name field concatenates the first name and the last name field and makes a single full name field.

Create an formula for text field in Salesforce Classic

So with this, we understand how to create a formula for the text field in Salesforce Classic.

Conclusion:

In this complete blog, we have learned how to create a formula for the text field in Salesforce we simply choose the object and select the formula field that is present under the object and after that fill the formula field label and number and choose the text field and then established the field level security and then add the page layout for the field and click on save for creating the formula text field.

This formula text field can concatenate the two fields and make a single field Like the full name field contain the combination of first name and last name field.

I hope you read the complete article and get the complete idea related to how to create the formula for the text field in Salesforce.  I have also explained all the steps of creating the formula for the text field in Salesforce Lightning and Salesforce Classic.

You may like to read