How to create lookup relationship in salesforce
How to create lookup relationship in salesforce :- Lookup relationship in Salesforce is one type of Object Relationship in Salesforce. In our previous Salesforce Tutorial we have learned about how to create master detail relationship in Salesforce. Lookup relationship is a one to many relationship created between two object and the bonding formed between the object is “loose bonding”.
A lookup relationship connects one object record to another object record by using a lookup field. It is commonly used when the child record can exist independently of the parent record. For example, a Visit record can optionally refer to a Sample record, or a Contact can optionally refer to an Account depending on the data model used in the org.
What is lookup relationship in Salesforce?
What is Lookup Relationship in Salesforce.
- Lookup relationship is one type of relationship that forms a loose bond between two Salesforce objects.
- In a lookup relationship, the child-side record can usually be saved without selecting a parent-side record, unless the lookup field is made required.
- Cascade delete is not automatic in the same way as master-detail; review the lookup field deletion behavior during setup.
- The lookup field can be placed on selected page layouts and can be optional or required based on the business rule.
- No native Rollup summary fields can be created in an ordinary Lookup relationship.
In current Salesforce setup, a lookup field can also be configured more strictly if the business rule requires it. For example, you can make the field required, set field-level security, add the field to selected page layouts, and decide how the lookup should behave when the referenced record is deleted. The main point is that lookup relationships do not create the same ownership, security inheritance, and tight dependency that a master-detail relationship creates.
Lookup relationship example in Salesforce data model
Assume that we have two custom objects named Sample and Visit. A Visit record can refer to one Sample record through a lookup field. One Sample record can appear in the related list of many Visit records. This is a typical one-to-many lookup relationship.
| Salesforce object | Role in this tutorial | What the lookup does |
|---|---|---|
| Sample | Related object / parent side | Stores the record that Visit can refer to. |
| Visit | Object where lookup field is created | Stores the lookup field that points to Sample. |
Lookup relationship vs master-detail relationship in Salesforce
Before creating a lookup relationship, confirm that lookup is the right relationship type for your Salesforce data model. The table below summarizes the practical difference between lookup and master-detail relationships.
| Feature | Lookup relationship | Master-detail relationship |
|---|---|---|
| Record dependency | Child record can usually exist without a parent unless the lookup is made required. | Detail record must have a master record. |
| Ownership and sharing | Child record has its own owner and sharing behavior. | Detail record inherits ownership and sharing from the master. |
| Roll-up summary | Native roll-up summary fields are not created on ordinary lookup relationships. | Roll-up summary fields can be created on the master object. |
| Deletion behavior | Deletion behavior is configured for the lookup field, commonly clear the value or restrict deletion. | Deleting the master normally deletes the detail records. |
| Best use case | Use when records are related but not tightly dependent. | Use when the detail record must depend on the master record. |
How to create lookup relationship in salesforce?
To create lookup relationship in salesforce user must navigate to Setup | Build | Create | Object | Child Object (Samples).
In Salesforce Lightning Experience, the equivalent path is Setup → Object Manager → select the object → Fields & Relationships → New. The screenshots below use the older Setup navigation, but the field creation choices are the same: select the object where the lookup field should be stored, create a new field, choose Lookup Relationship, and complete the wizard.
Now go to Build | Create | Objects.
- Now select your Child object (Sample).
The lookup field must be created on the object that should store the reference. In this tutorial, the lookup field is created on the Sample/Visit example object used in the screenshots.
- Now go to Custom Fields and relationship.
- Now click on New Button as shown above.
Select Lookup Relationship as the Salesforce field type
Select Lookup Relationship as shown above and click on Next button.
Choose this option when you want the current object to contain a field that references another Salesforce object. Do not choose master-detail unless the child record must depend on the parent record for ownership, sharing, and deletion behavior.
Select the related object for the Salesforce lookup field
Step 2: -Selecting Related to Object.
Now select the object to which this lookup field should point. In this example, the lookup field connects the Sample and Visit objects used in the screenshots.
The related object is the object that users will search for and select in the lookup field. Choose the object carefully because changing the target object later usually means creating a new relationship field and migrating data.
Enter field label and field name for the Salesforce lookup
Enter Field label, Field Name and click on Next button.
The Field Label is the name users see on record pages. The Field Name is the API name used in formulas, reports, integrations, Apex, and metadata. Use a clear label that describes the related record, such as Visit, Account, Manager, or Project.
Set field-level security for the Salesforce lookup relationship
Step 4 :- Establishing Field Level Security for reference field.
Make sure the Field level Security is visible for all profiles. Now click on Save button.
Field-level security controls which profiles can see or edit the lookup field. For a business-critical lookup, give edit access only to the users who should maintain the relationship. If users can see the related list but cannot see the lookup field, check field-level security first.
Add lookup relationship field to Salesforce page layouts
Step 5 :- Select the Page layout for child object field.
- Click on Next button.
Select the page layouts where users should enter or view the lookup value. If the lookup should be optional, do not mark the field as required on the page layout. If the business process needs the lookup value for every record, make the requirement clear through field settings, validation rules, or page layout configuration.
Add Salesforce related list for lookup relationship records
Step 6 :- Adding custom related lists.
Click on Save button as shown above. Now successfully we have created lookup relationship in salesforce.
Now open Sample object detail page and we find create lookup relationship between Sample object and Visit object is created in salesforce.
The related list lets users open the parent-side record and see the child records that point to it through the lookup field. If the related list is not visible after saving, edit the related object’s page layout and add the related list manually.
Testing Lookup Relationship in Salesforce
- Go to Sample Object as show below and create a new Sample record.
As shown below, the Sample record has the Visit lookup field and the field is not mandatory in this setup. If we create a record without entering the visit lookup value, the record is saved because this lookup relationship is configured as a loose relationship. But in a Master detail relationship, we cannot create a detail record without entering the master record because master-detail forms a tight relationship.
For a cleaner test, create one record with the lookup field populated and one record without the lookup field populated. The first record should appear in the related list of the selected parent record. The second record should save independently if the lookup field has not been made required.
Salesforce lookup relationship settings to review after creation
- Lookup filter: use a lookup filter if users should select only records that match specific conditions.
- Required value: decide whether the lookup should be optional or mandatory for new records.
- Delete behavior: check what should happen when the referenced lookup record is deleted.
- Related list label: verify that the parent-side related list label is clear for users.
- Reports: check whether users need a custom report type to report across the two objects.
Salesforce lookup relationship limits and indirect lookup note
Salesforce counts relationship fields against object limits. A custom object can have up to two master-detail relationships, while lookup relationships are included in the object relationship and custom field limits available for that object. Since org limits can vary by edition and configuration, check Setup → Object Manager → Object → Object Limits before adding many lookup fields to the same object.
An indirect lookup relationship is a different relationship type used with external objects. It is not the same as the normal lookup relationship shown in this tutorial. Use an indirect lookup only when you are connecting an external object record to a Salesforce record through matching key fields.
Reference links: Salesforce Trailhead object relationships and Salesforce Help: custom object relationships.
Common issues while creating lookup relationship in Salesforce
- Lookup field is not visible: check field-level security and page layout assignment.
- Related list is missing: edit the related object’s page layout and add the generated related list.
- Users can select the wrong records: add a lookup filter to restrict selectable records.
- Cannot create another relationship: check object limits for custom relationship fields and custom fields.
- Lookup value is cleared unexpectedly: review the lookup field deletion behavior and user permissions.
QA checklist for lookup relationship in Salesforce tutorial
- Confirm that the lookup field is created on the object that should store the reference.
- Verify that the related object selected in the wizard is the correct parent-side object.
- Check field-level security so the intended profiles can see or edit the lookup field.
- Open the page layout and confirm that the lookup field and related list are visible where needed.
- Create test records with and without the lookup value to confirm the expected optional or required behavior.
Lookup relationship in Salesforce FAQs
What is an example of a lookup relationship in Salesforce?
An example is a Visit object with a lookup field to a Sample object. Each Visit record can refer to one Sample record, and one Sample record can have many related Visit records shown in a related list.
What is the primary purpose of lookup relationship in Salesforce?
The primary purpose of a lookup relationship is to connect records from two objects without making one record tightly dependent on the other. It helps users navigate related records and supports reporting, filtering, and data organization.
How many lookup relationships can be created in Salesforce?
The number depends on the object limits in the org. Salesforce counts lookup and master-detail fields under relationship and custom field limits. Check Object Manager → Object → Object Limits for the exact number available on a specific object.
Can a lookup relationship field be required in Salesforce?
Yes. Although lookup relationships are commonly optional, an administrator can make the lookup field required through field settings, page layout settings, or validation rules depending on the business requirement.
Can lookup relationships create roll-up summary fields in Salesforce?
Native roll-up summary fields are not created on ordinary lookup relationships. For native roll-up summary behavior, Salesforce commonly uses master-detail relationships. For lookup-based summaries, admins often use Flow, Apex, or an approved package depending on the requirement.
Summary of creating lookup relationship in Salesforce
In this Salesforce tutorial we have learned about How to create lookup relationship in salesforce. In our upcoming Salesforce Tutorial we learn about How to create Many to Many relationship in Salesforce.
A lookup relationship is suitable when two Salesforce objects need to be connected but the child record should remain more independent than it would be in a master-detail relationship. After creating the lookup field, always test field visibility, page layout placement, related list behavior, and lookup deletion settings before using the relationship in production data.
TutorialKart.com












