This app provides all the necessary lightning components to enable inline editing for related list.
The app provides lightning components for the client side and a controller to handle metatdata and data manipulation in the backend. The controller can handle any type of object (standard and custom as well). To achieve this, I massivelly used the Salesfroce Rest API mainly "sobject" API(s).
Display all the related lists. The list of related list is extracted from the object layout (See below: View mode and edition mode).
Display a specific related list based on the label. Using the label is more user friendly. The related list label can set from the app lightning builder.
Both components are availables in the lightning app builder. So just drag&drop and enjoy.
The package contains Unit Tests for Apex classes and Static Resources for Rest MockUp.
In this tutorial, I will show you how to use RelatedListEditor components from deployment to testing.
-
Each user using any page with RelatedListGrid should have a profil with API enabled.
-
Create subdomain on your salesforce instance. See My Domain Setup for more details.
-
Add your salesforce instance as "Remote Site". See Remote Site Setup for more details. Here is my entry for this tutorial:
At this step, you will be able to see 2 new custom lightning components in the "lightning app builder".
To change the account lightning page and use RelatedListGrid components, remove the 'Out Of The Box' components above and drag and drop the new component 'RelatedListDataGridsComponent'.
Note that:
- RelatedListDataGridsComponent is used to display all the related list defined in page layout
- RelatedListDataGridComponent (without s) is to display a specific related list and you have specify the related list 'label' not the name.
When you display only one related list, you have different options to play with like filtering, sorting (see screenshot below):
-
Filter example : If we want to filter only Closed Won Opportunities : {"StageName":"Closed Won"}
-
Aggregate example : If we want to display the total row at the end representing the sum of opportunities amount : {"Amount":"sum"}
-
Default Values example : If we check 'Can Create Object', the component use default values property to initialize the new object when you hit (+) button. This is usefulf to set the non displayed fields. The parent id for exemple. {"accountid":"$recordId", "name":"Opp 1", "closedate" : "2018-07-07","stagename":"Needs Analysis"}
Note that: Use $recordId to reference the current record Id and dot not forget to user low case for field name.
-
Sort example : If you want to sort the grid, set the field name : Amount
-
Order exemple : 'asc' or 'desc'