How to Use Formula Field to Capture Lookup Field in Salesforce

We use the formula field in Salesforce to calculate the values based on the other field values involving the lookup field value. Formula field permitting us to perform calculations and many more.

In this Salesforce tutorial, we will learn how to use the formula field to capture the lookup field in Salesforce.

You have come to the right place to learn this process. We learned this topic in both the editions of Salesforce Lightning and Salesforce Classic. So, let us show some examples.

How to use the formula field to capture the lookup field in Salesforce Lightning

Here we will learn how to use the formula field to capture the lookup field in Salesforce Lightning.

Let us take a real-life example, In Salesforce there is an opportunity object present that can track the sales opportunities and every opportunity is related to a particular product. Here the opportunity object has a lookup field called product_c that refers to the product object.

Here we can create the formula field on the opportunity object that captures the name of the product related to each opportunity.

Here are the following Steps:

1. Login into the Salesforce account –> Click on the gear icon –> Go to Setup –> Click on the object manager tab –> Select opportunity object.

How to use the formula field to capture the lookup field in Salesforce

2. Click on the Field and Relationship –> Click on the new button –> Select the Formula Checkbox.

How to use the formula field to capture the lookup field in Salesforce Lightning

3. Now choose the output type. Here we fill the field label as Product Name and then fill in the field name which is automatically filled by a simple click on the field. Now choose the formula return type.

See also  Salesforce Formula to get Last Day of Month

Here we are choosing the formula return type as a text. After choosing the formula return type click on the next button.

Use the formula field to capture the lookup field in Salesforce

4. Click on the advanced formula subtab –> Click on the insert field option –> Select the opportunity –> Click on the product –> Select the product name –> Product name to add to the formula field.

5. Now check the syntax and now error will occur it means our formula is correct and click on the next button.

Use the formula field to capture the lookup field in Salesforce Lightning

6. Select the profiles we want to grant edit access to this field via field-level security. The field will be hidden from all profiles if we do not add to it field-level security. Click on the next button.

Salesforce use the formula field to capture the lookup field

7. Select the page layouts that should include this field. The field will be added as the last field in the field two-column section of these page layouts. Click on the save button.

Salesforce Lightning use the formula field to capture the lookup field

8. Click on the App Launcher –> Click on the Sales –> Select the opportunity object –> Opportunity Record page is open –> Select one record.

9. Under this record page, we can see that the Product field is present which is a lookup field and we pick up the product through the lookup icon in the next field.

We can see is the product name field which has the same name as the product because the product is the formula field is linked with this product name field.

How to use formula field to capture the lookup field in Salesforce

In this way, we understand how to use the formula field to capture the lookup field in Salesforce Lightning. Let’s Proceed further and learn how to use the formula field to capture the lookup field in Salesforce Classic.

How to use the formula field to capture the lookup field in Salesforce Classic

Here we will learn how to use the formula field to capture the lookup field in Salesforce Classic.

See also  Salesforce Formula Field to Calculate Age

Consider a scenario, suppose there is a company that is based in the United States of America and I am working in this company as a manager and managing job applications in Salesforce.

Inside the job application form, there is a lookup file called candidate that can refer to the candidate object and here we want to create a formula field on the job application object that captures the email address of the candidate that can related with every job application.

Here are the following steps:

1. Log in to your Salesforce account –> Click on Profile Picture –> Select Switch to Salesforce Classic.

Click on the setup option –> Enter the object in the Quick Find box. Select the object option –> select the job application object.

How to use the formula field to capture the lookup field in Salesforce Classic

2. Now scroll to the bottom, there is a job application custom fields and relationships section present. Here, we want to create a new field, so we click on the new button.

Our data type page is open –> Select the Formula data type.

Use the formula field to capture the lookup field in Salesforce Classic

3. Here we fill the field label as Candidate Email and then fill in the field name. Now choose the formula return type. Here we are choosing the formula return type as a text. Click on the next button.

Salesforce Classic use the formula field to capture the lookup field

4. Click on the advanced formula subtab and then click on the insert field option and then select the job application and then Click on the candidate after that Select the candidate email to add to the formula field.

5. Now check the syntax and now error will occur it means our formula is correct and click on the next button.

How to use formula field to capture the lookup field in Salesforce Classic

6. After creating the formula now establish the field-level security. Select the profiles we want to grant edit access to this field via field-level security. Click on the next button.

Use formula field to capture the lookup field in Salesforce Classic

7. The field will be added as the last field in the field two-column section of these page layouts. This field will not appear on any pages if you do not select a layout. Click on the save button.

Salesforce Classic use formula field to capture the lookup field

8. Go to the Home tab –> job application record page is open –> Select one of the records –> Select the Salesforce job app

See also  Salesforce Formula Add Year to Date

We can see that the candidate’s name is shown under the candidate name lookup field, and a record related to the candidate, such as the candidate’s email, is shown under the candidate email field because the formula field links it.

How to use a formula field to capture the lookup field in Salesforce Classic

This explains how to use the formula field to capture the lookup field in Salesforce Classic.

Conclusion:

I hope you read the entire article and get a clear idea of how to use the formula field to capture the lookup field in Salesforce. I have also explained all the steps for using the formula field to capture the lookup field in Salesforce Lightning and Salesforce Classic.

You may like to read: