Skip to content
This repository has been archived by the owner on Jan 27, 2024. It is now read-only.

A Lightning Component that displays records from a List View ID

Notifications You must be signed in to change notification settings

douglascayers/sfdx-listview-datatable-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

List View Data Table Example

Demonstrates how to use List View Describe information to query for sobject records and display them in a Lightning Component using lightning:datatable.

The UI-API also has ability to retrieve Records and some List View Metadata, but it does not return the data type of each field to know if a field is text, phone, number, etc. which is important when specifying the columns of the <lightning:datatable> component.

Getting Started

  1. Clone this repository
git clone https://github.com/DouglasCAyers/sfdx-listview-datatable-example.git
cd sfdx-listview-datatable-example
  1. Use Salesforce DX CLI to create a scratch org and push the source to it
sfdx force:org:create -f config/project-scratch-def.json -a lvdt -s
sfdx force:source:push -w 10
sfdx force:org:open
  1. Generate a password for the scratch org, you will need your org's username and password in the next step.
sfdx force:user:password:generate
  1. Follow these instructions to create the necessary Connected App, Auth. Provider, and Named Credential to allow Apex used by a Lightning Component to invoke Salesforce REST API.

  2. Create some test records for an object and create a list view for them. Note the list view filter id in the browser's address bar (e.g. 00Bxxxxxxxxxxxx)

  3. Use App Builder to add the custom component ListViewDataTable to a Lightning Page (e.g. a Home Page or Record Page). Specify the Named Credential and List View ID design attributes in App Builder.

    screen shot

Inpsiration

Inspired by Peter Churchill who asked via #askforce on Twitter:

In Classic, I can use getListViewOptions with a Standard Set Controller to display list views in a dropdown, and then get the records for that list using SetFilterId. Is there any equivalent in LEX components, or an alternative that achieves same result?

Disclaimer

This project serves as a quick proof-of-concept and as-such does not provide any unit tests. It is for educational purposes.

About

A Lightning Component that displays records from a List View ID

Resources

Stars

Watchers

Forks