In this blog, we will develop a generic record handler lightning component, which will be helpful in viewing and editing any record of any object.
This component is developed using very helpful base lightning components, lightning:datatable and lightning:recordForm. It will be helpful in:
- Viewing any object in your Salesforce Org.
- Viewing and editing records of the selected object from the same page. This works for both standard and custom object.
You can replace the datatable used in this example with a paginated datatable, which I have explained in below blogs.
- Lightning Pagination with page number navigation – Using Client Side Controller
- Lightning Pagination – Using Server Side Controller And Client Side Cache
GenericRecordHandler.cmp – Lightning Component
GenericRecordHandlerController.js – Controller
GenericRecordHandlerHelper.js – Helper
GenericRecordHandler.apxc – Apex Controller
There are lot of modification can be done in this component as per your use case. Like having a paginated data-table, suppying filter in SOQL instead of fetching 200 records etc. Its totally upto you how you would use this component. Paste your query in the comments.