How to Create Lookup Relationship in Salesforce

I worked as a Salesforce Administrator for an organization that was hiring employees across various departments. As part of creating profiles for these new employees, we needed a way to assign them to their respective departments easily.

To do this, we wanted a field that would allow users to search for and select the appropriate department for each employee.

So that, when users open a department record, they should see a list of all new employees assigned to that department. To meet this requirement, we used a lookup field in Salesforce that provides this functionality.

Here, I will explain the lookup relationship field in Salesforce. In this section, we will explore the types of relationships available in Salesforce and demonstrate how to create a lookup relationship using an example.

Types of Relationships in Salesforce

The following are the five types of relationships in Salesforce:

  1. Lookup Relationship:
  2. Master-Detail Relationship:
  3. Self Relationship:
  4. External Lookup Relationship:
  5. Many-to-Many Relationship:

Lookup Relationship in Salesforce

In Salesforce, a lookup relationship is loosely coupled. It establishes a relationship between two Salesforce objects, allowing us to access records of other objects in the relationship.

The lookup relationship is a one-to-many (parent-child) type of relationship, and the lookup field is always created on many sides (child). In a lookup relationship, the child record does not depend on the parent record; it can exist without the parent.

Create a Lookup Relationship in Salesforce

Suppose there are two objects: a Contact object and a Custom Object named Bank Account_c. You need to relate the bank account record to the contact record so that you can add the bank account to the contact from the contact object.

Using the following steps, we can achieve the above requirement by creating a lookup relationship between the bank account and the contact object. In this scenario, the Contact Object is a child object because one bank account can have many contacts, so we will create a lookup field on it.

  1. Go to Object Manager. -> Search the object on which you want to create a Lookup Field. -> Click on it. Here, I have selected a Contact object.
Lookup Relationship in Salesforce
  1. Then click on Fields & Relationships, and to create a new field, click on the New button.
salesforce lookup field
  1. Select Data Type as Lookup Relationship, then click on the Next button.
lookup field salesforce
  1. Now, in the Related To field, we need to select with which object we want to establish a relationship. Here, I have selected the Bank Account object.
object relationships in salesforce
  1. Then enter Label, which will appear on the Detail Page of the contact object. The Field Name is the API Name, which will automatically populate.
what is lookup relationship in salesforce
  1. Then enter the Child Relationship Name.
  • Required: If you want to lookup a field that should not be empty, then you can make it required.
  • Auto add to custom report type: If you don’t check this field, it will not be added to existing reports.

Lookup Filter:

  1. Lookup Filter filters records based on the condition or formula you defined. You can also make the lookup field required.
    • The Lookup Filter in Salesforce is used to filter required records according to our needs. After applying the lookup filter, the lookup field will display only those records according to our defined condition.
lookup filter criteria in salesforce
  1. In the Field Level Security, you can decide to which Profiles the lookup field will be visible. Then click on the Next button.
lookup filter in salesforce
  1. Enter the Related List Label, which will display as a related list Parent Object(Bank Account). Then click on the Save button.
what is lookup filter in salesforce
  1. Now, here you can see the Lookup Relationship has been successfully created.
related lookup filters
  1. Now go to the Contact object, and as you click on the Bank Account lookup field, you will see bank account records, and you can select any record from the bank account object.
lookup filter criteria in salesforce

This is how we can create a lookup relationship in Salesforce.

Conclusion

I hope you now have an idea about the Lookup Relationship in Salesforce and how to create a Lookup Relationship field. In that, we have seen the types of relationships in Salesforce: Lookup relationship and Lookup Filter.

We have also seen the difference between lookup and master details and how to create a lookup relationship in Salesforce with examples and explanations.

You may also like:

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.