Skip to main content

Lookup Relationship Status: It's complicated

Lookup relationship fields

Salesforce allows the linking of different object data using lookup fields. But how do you determine the right lookup type to use? Let's review the different options.

What kind of lookup relationships can I use?

Relationships between objects in Salesforce are created though custom field types called Lookups. These field types can be on standard and custom objects and enable linking of record data from one Salesforce object to another object. For example, linking one or more Opportunities to an Account.

There there are two (2) lookup field types to choose from:
  1. Lookup
  2. Master-Detail

Both lookup types can can be used to connect Salesforce objects and relate data together to represent 1:Many / hierarchical relationships. Without getting too serious, let’s put some labels on our relationship setup:
  1. Related (child / many) record = Many (e.g. opportunity)
  2. Lookup (parent / 1) record = 1 (e.g. account)

So now that we know the types of lookup relationships we can have, which one do we want to use?

Feature comparison

Feature Lookup Master-Detail
Always Required No Yes
Default Sharing rules Independent Controlled by Parent
Cascade deletion No 1 Yes
Record Access Independent between related and lookup records Same as Parent record
Report on Track History Yes No 2
Create Rollup Summary Fields No Yes
Rollup Summary Filter N/A Yes 3

So which lookup type should I use?

So you are ready to create a Salesforce object lookup field but still don’t know which is the right one for you? Ask yourself these questions before deciding:
  1. Can a lookup field ever be blank (null) when a new related record is created or edited?
  2. Does ownership of a related record need to be different to the lookup record?
  3. Would cascade deletion of related child records cause data issues?
  4. Will record access to related records be different to lookup record access?
If you answered Yes to any (or all) of these questions then a Lookup relationship is the way forward. Otherwise, you can use a Master-Detail lookup relationship field.

But what if I want to change an existing lookup relationship?

If you want to take your Salesforce lookup relationship to the next level, you can convert a Lookup to a Master-Detail type. Before taking the plunge, take a moment to reflect on the following:
  1. Is the lookup field populated on all related records?
  2. Do you want to report on track history field changes?
  3. Are there a lot of reports based on the existing field relationship type?

Additional considerations before proceeding

  • The Master-Detail field lookup type requires that all lookup fields are populated on related records prior to conversion.
    • If you change a relationship field type on an object from lookup to master-detail with blank lookup field values, you’ll get an error reminding you to update any missing data first then convert the field type.
  • Track history object reporting is not supported for master-detail fields as of the Winter 19 release.
  • Existing reports based on the previous field relationship will need to be recreated.
    • The previous reporting object relationships are no longer valid after changing the field type to a Master Detail type. This could create a lot of work to recreate existing reports. A silver lining to this is the opportunity for some system maintenance to see if reports are actually being used and to delete reports that are outdated or no longer being run.  See the "Impact of Relationships on Reports" section of the Considerations for Object Relationships help article for further details. 

Recap

Data relationships in Salesforce can be daunting. But asking yourself a few questions before jumping in can help find the right relationship solution for long-term related data happiness.

Comments

Popular posts from this blog

How to find track history enabled fields in your Salesforce instance

Field history tracking is a Salesforce feature that allows tracking of changes to object field changes over time.  In today's post well cover: What is field track history in Salesforce Changes to field change history data retention coming in the Spring 19 release How to use SOQL and workbench to find fields with track history enabled What is Field Track History? Salesforce comes out of the box with field change tracking functionality for standard and custom object fields. When enabled, up to 20 fields can have changes tracked for most objects in Salesforce. The field value changes are stored in object "history" tables and can be viewed from the Object History related list on an object record, from history reports, weekly data exports, data loader and API access. Changes to field tracking history data in Spring 19 The Spring 19 release, which goes live in February 2019, brings the enforcement of  Salesforce’s policy for retaining field tracked change da

Spring 18 & Summer 18 certifications due Dec 14, 2018

It’s the most wonderful time of the year Family, gifts, traditions, reflection, candles and a roaring fire place or a day at the beach. And what holiday season would complete without salesforce maintenance exams. Wait, what? With everything going on in the silly season that is the holidays don’t forget that Salesforce  certification maintenance exams for the spring 18 and summer 18 releases are due no later than December 14, 2018. Make sure that you continue to be recognized as a leading professional within the Salesforce community by completing the exams. Recap What : Salesforce certifications maintenance exams for spring 18 and summer 18 Releases When : December 14, 2018 How : Trailhead and Webassesor  Why : If you don’t complete the certification exams by the deadline, your certifications will lapse and you’ll have to resit the tests to be a certified salesforce professional

Add an image to a login flow

Login flows allow you to run automation or display  messages after a user successfully logs in to Salesforce. In this post, I'll show you how to add an image to a login flow in Salesforce using a URL in a screen flow. For this setup you'll need: Login flow Custom label HTML/CSS knowledge Let's get started. Create a custom label Go to Setup > Custom Labels Click New Enter a name for the label eg LoginFlow Image Enter LoginFlow as the category Enter the following HTML snippet then click Save   <img src="URL OF THE FILE TO DISPLAY alt=“file description”> Pro Tips Using a custom label allows for the image to be updated without changing the flow logic. Add CSS to style the image and any text you want to display. Create a screen flow Go to Setup In setup search enter flow Select Flows Click New > Screen flow Drag a screen element on to the canvas  Enter a name and description for the screen Add a text output component In the formula editor select flow > label