Create Lookup Relationship in Salesforce

Relationship determines the dependency of values. In a Lookup Relationship, one object can be Look up from the related tab on another object. We can create either a one-to-one Lookup relationship or a one-to-many Lookup Relationship. In a one-to-one Lookup Relationship, a single object can contain only one object while in a one-to-many Lookup Relationship, a single object can contain many objects together. The Account to Contact Relationship is the best example of a one-to-one Lookup Relationship because a single account can have multiple contacts together. In this article, we will learn How to Create a Lookup Relationship in Salesforce and create custom Relationship fields in Salesforce.

What is Lookup Relationship?

When one object can be Look up from the related tab on another object or a relationship that links one object to another, called Lookup Relationship. It is the loosely coupled relationship that allows us to connect one object to another in a one-to-many fashion.

A Lookup Relationship can link a standard object to a custom object or a custom object to a standard object. In a Lookup Relationship, if we delete the parent record, the child record will not get deleted.

Example: Account to Contact Relationship.

Why Lookup Relationship?

Relationships are always complicated either in our real life or in database example. We use Lookup Relationship only if objects are related in some cases like sometimes, contact is linked with the particular account but sometimes it’s just a contact.

In a Lookup Relationship, both parent or child object behaves as stand-alone objects and contains their own tabs in the User Interface (UI).

Create a Lookup Relationship in Salesforce

The field of the child object gets its values from the record of the parent object. If the record of the parent object gets deleted, the field of the child object becomes empty.

Before starting to create a lookup Relationship, create a custom object called Favourite and add a field to this object. There are few steps to create a Lookup Relationship as follows;

  • Log in to Salesforce
  • Click on the Gear icon and go to the Setup menu.
  • Click the Object Manager tab.

Lookup1.jpg

  • Click Create then click the Custom Object from the drop-down.
Create Custom object to create Lookup Relationship
Create a Custom object to create Lookup Relationship
  • Enter Favourite in the label field and Favourites in the Plural Label field.

Lookup3.jpg

  • Enter the description in the given field.
  • Select data type as Auto-Number
  • Check the box “Launch New Custom Tab Wizard after saving this custom object”. This box available only when the custom object is created for the first time.
Create Custom object to create Lookup Relationship
Create Custom object to create Lookup Relationship
  • Click Save
  • Select Tab style or create your own style

Lookup5.jpg

  • Click Next, Next, and Save.
  • Click the Fields & Relationship on the Object Manager page.

Lookup6.jpg

  • Click New to create a custom field.

Lookup7.jpg

  • Select Data Type as Auto Number and then click Next
Create lookup Relationship
Create lookup Relationship
  • Enter Favourite Name in the Field label, FA-{0000} in the Display Format and 1 in Starting Number field then click Next.
Create lookup Relationship
Create lookup Relationship
  • Click Next, Next, and Save

Create a Custom Relationship Field

In this section, we will create two custom relationship fields on the above-created object. To create a custom relationship field, first, we will create a Lookup Relationship that lists the users who select the Favourite for a property. Below are the steps to create a Lookup Relationship as follows:

  • Login to Salesforce
  • Click to the Setup menu
  • Go to the Object Manager then go to Favourite or enter Favourite in the Quick Find Box.
Create a Custom Relationship Field- Lookup Relationship
Create a Custom Relationship Field- Lookup Relationship
  • Click Fields and Relationship from the sidebar menu

Lookup11.jpg

  • Click the “New” button.

Lookup12.jpg

  • Choose Lookup Relationship
Create Lookup Relationship
Create Lookup Relationship
  • Click Next button
  • Select the other object to which the above-created object (favorite) is related in the Related to field
Create Lookup Relationship
Create Lookup Relationship
  • Click Next button
  • Enter Contact in Field name. The child Relationship Name field will automatically be captured by the system.

Lookup15.jpg

  • Click Next button
  • Click Next, Next, and then Save
Create Lookup Relationship between Favourite and Contact object
Create Lookup Relationship between Favourite and Contact object

Now, we have successfully created a Lookup Relationship between Favourite and Contact.

 

About the Author: Admin

You May Also Like

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Join Our Community Of Bloggers