Salesforce Implementation Guide - Related Record Components
At its core, Salesforce fundamentally functions as a relational database. That is, it not only stores data from various objects and records but allows those objects and records to be related to one another, which in essence “connects” them and shows their relationship.
For example, a basic relationship in the standard Salesforce data model is the classic Account and Contact relationship. Accounts are organizations you sell to or do business with, while Contacts are individuals who work at those organizations in various roles, from CEO to frontline workers and everyone in between.
Contacts are “related” to Accounts to show that they work at a certain organization and fulfill a role there. An example would be Mark Zuckerberg; he would be considered a Contact for the “Facebook” Account in Salesforce with a Title of CEO.
Challenge: The nature of this relational model allows for some powerful reporting and insights while using Salesforce, but there are some challenges for end users in navigating the more dispersed data model. For instance, if I wanted to look at a Contact record related to a given Account but wanted to see more information about that Account beyond the name, I’d have to click on the Account link and navigate to the record directly, which would take me away from my Contact record (see screenshot).
However, using some simple declarative configurations you can set up a Lightning page to display information about a related record directly on the page, without the User needing to navigate away from their current record to view it. They can even make updates or create new related records via this method.
Solution: Historically, the only way to solve this was groups of formula fields or (gasp) a Visualforce page. Not any more thanks to Related Record components! This feature in Lightning page layouts allows you set up a window of sorts into a related record and display whatever data about that record you desire. It requires a little bit of preparation and configuration but is a straightforward process I will outline below.
Objective: For the sake of example, let’s create a Related Record component on our Contact page layout that will display critical data from the related Account record without having to navigate directly to it.
Step 1: Build a New Quick Action
The first step to creating a Related Record component in Lightning is to create an “Update a Record” Quick Action on the object that you want to display the data for in your component.
Since we want to display Account data on our Contact record, we will create a new Quick Action under the Account object. We can accomplish this by going (in the Lightning interface) to the Lightning cog in the upper right-hand corner of Salesforce, clicking “Setup”, then navigating to “Object Manager”, “Account”, and “Buttons, Links, and Actions” (see screenshot).
Once you click on “Buttons, Links, and Actions” click on “New Action” to bring up the setup screen. You will then configure your new “Update a Record” Quick Action for use in the component. Enter the following configurations (see screenshot below for guidance):
Action Type: Update a Record
Label: Account Data (or any other name you want to give)
Name: Account_Data (this should auto-populate based on your label above)
Click Save to create the Quick Action record.
Step 2: Configure Your Quick Action with Desired Fields
The next step to creating a Related Record component in Lightning is to update the layout of the Quick Action we just created to determine what fields from the Account we want to display in the component.
To navigate to the layout editor, go to the “Buttons, Links, and Actions” tab again, select your new Quick Action and click “Edit Layout”.
You will then be prompted to drag and drop any fields that you want onto the Quick Action layout – these will be the fields that are displayed in the Related Record component when you set it on the Lightning page layout later (see screenshot).
When you are done setting your desired fields, click the “Save” button above the layout editor to save your layout for the Related Record component (see screenshot).
NOTE: Avoid placing more than a dozen fields on the layout as adding too many fields can bog down the component and confuse end-users
Step 3: Add your Related Record Component to the Lightning Layout
Now that we have created our Quick Action, we are ready to set up the Lightning component to display our Account data on our Contact page layout.
To do this, we need to go to a Contact in the system, click the Lightning cog in upper right-hand corner of Salesforce, and select “Edit Page” (see screenshot).
Next, you need to click and drag the “Related Record” Lightning Component from the Standard components section on the left-hand side of the screen.
You can then click, drag, and drop this component anywhere on the Lightning page you want it to go – for our example we will place it in the center column to keep the information on the Account front and center for end users.
Enter the following configurations (see screenshot below for guidance):
Header Label: Account Data
Lookup Field: First Lookup = Account Name / Second Lookup = Use This Account
Update Action: Account Data (this is the name of the Quick Action we created earlier)
Create Action: New Account (this is a standard Quick Action you can use to create Account records from this component)
Click Save in the upper right corner to create the Quick Action record.
Step 4: Marvel at Your Greatness!
Click the back arrow in the upper left-hand corner of the Lightning page layout setup screen to return to your Contact record and view your new Related Record component displaying Account Data all from a single location (see screenshot).
NOTE: Not only can you now see related data from the Account, but you can also edit the fields in the Related Record component to update the Account data directly form the Contact! Just bear in mind that the ability to edit these fields is dependent on your security settings as a User!
You can repeat this technique for multiple related objects to a record if you want to display more data from additional objects. For example, a Case might have Related Record components that allow you to see data from the related Account and Contact on the Case page layout without having to click into those related records directly.
This technique works both with standard and custom objects, the only stipulation being that the object that will host the Related Record component MUST have a lookup or master-detail relationship field on it that relates it to the object that you want to display data for. If there is not an Account relationship field on an object, you will not be able to have a Related Record component for the Account on that object until you construct it. It is important to spend time configuring system functionality that will provide scalability and business process alignment as it applies to your Salesforce implementation and ongoing optimization efforts. Thank you for the read and good luck!