Related List with Inline Edit | Lightning Component Salesforce

Hey Users,

Sometimes it is painful if you have to edit multiple child records and you have to open each record and update them. This component will make Related List with Inline Edit support. You can edit multiple rows and save them instantly. Also, if any error will occur, it will be visible instantly as Toast Message.

This component supports multiple salesforce datatypes and all necessary validations are already present. Pros and cons of the component are-

  • Single Unit Component
  • Major Exceptions Already Handled.
  • Inline Edit based on field permission. If no permission, no Inline Edit.
  • Auto Scroll-bar if more than 5 Child Records are present.
  • Supports major SF datatypes like Text, Textarea, Picklist, Number, Percent, Currency, Date, Time, DateTime, Checkbox, etc.
  • Lookup, Rich Text Area, Geo-Location are yet in view mode only.

Demo GIF:

related list with inline edit lightning salesforce gif

Also Check, Multi-Select Lookup Lightning Component


Step-1: Create an Apex controller

Our apex controller will have all the necessary Validations. Apex class will fetch the child records and save the records. Here we are using a wrapper class to pass data to the lightning component. Go to Dev. console > File > New > Apex Class.

We need to create an Exception class first to throw the custom exception.

Create MyException.cls Apex class.


Create AdvancedRelatedListController.cls Apex class and paste the below code.


Step-2: Create the AdvancedRelatedList Lightning Component.

For creating a new Lightning Component, go to dev. console > File > New > Lightning Component.

Now open the AdvancedRelatedList.cmp file and paste the below code.


Now open the controller file AdvancedRelatedListController.js and paste the below code.


Open the helper file AdvancedRelatedListHelper.js and paste the below code.


Open the helper file and paste the below code.


Now finally paste the CSS in the AdvancedRelatedList.css file.


Step-3: Now we will add the component on the record page.

Our component is ready to use. Let’s put it on the Record Detail Page. Go to your record > Click on setting Gear on top > Edit Page.

On the Lightning App Builder in the Left Pane, find Advanced Related List and drop it on the record page. Now you need to set the Header, Object API name, Fields API Name List, Icon Name, and check the checkbox if you want the Inline Edit button.

You can check the list of available icons here LDS Icons.

Add Advanced Related List to Lightning Page

Hurray… All Set… Now Save and Activate the Page from the top and click on the back Icon. Your Related List component is visible now.

Advanced Related List with Inline Edit Lightning Salesforce

Also Check:

For any queries or suggestions/queries, comment below.

Cheers … Happy Coding … ๐Ÿ™‚

Notify of
Inline Feedbacks
View all comments

Hi, I am getting a compile error when saving the apex class: Invalid type: MyException. Can you please provide some guidance on how to resolve this?


absolutely great and exactly what i need. however, i have no idea what the test class for the controller should look like. can you help here?


Any chance you have the test class ready to go?


Any chance you’ve converted this to a Lightning Web Component?


Thanks for sharing! Test class and eventually an LWC would be awesome! Looking forward to building this out and testing.


Hi, do you have the LWC version of the related list yet by any chance? We are running around looking for a solution for a relatedlist with inline editing and lookup fields.


This is awesome, Is it possible to show more than 5 rows and can you sort a column ?


Many thanks for the quick answer !


Hi Suyash, this is awesome, but I need a test class to deploy ? Do you have the code for it ?


Ok great I really want to deploy soon

John Doe

Anyway to get this to work with AccountContactRelation object? Trying to display any related contact while being able to edit.

Thank you!

Gretchen M. Goulet


I’m wondering if you could quote for me how much you would charge to….

  1. Complete the test Class and
  2. Alter this such that the Name renders as a link to the record like other standard related lists.