3

I'm asked to create a web component that shows the records of a custom listview when selected from a picklist just like in object tab. It should also have all the filters that I initially gave when creating the listview in object tab.

I searched for a whole day but couldn't find anything related to showing listviews for a lwc.

1
  • I previously wrote an answer about how to obtain the SOQL queries and results associated with List Views. As far as I know that approach is still viable, but you do have to make a callout to use it.
    – David Reed
    Jul 13, 2020 at 2:31

1 Answer 1

8

Take a look into the lightning/uiListApi module. It has below functionality

- Get list view records and metadata for a list view by API name

   import { LightningElement, wire } from 'lwc';
   import { getListUi } from 'lightning/uiListApi';
   import ACCOUNT_OBJECT from '@salesforce/schema/Account';

   export default class Example extends LightningElement {
        @wire(getListUi, { objectApiName: ACCOUNT_OBJECT, listViewApiName: 'AllAccounts' })
    propertyOrFunction;
   }

- Get list view records and metadata for a list view by ID

   import { LightningElement, wire } from 'lwc';
   import { getListUi } from 'lightning/uiListApi';
   export default class Example extends LightningElement {
     @wire(getListUi, { listViewId: '00BT0000001TONQMA4'})
     propertyOrFunction;
  }

- Get all list views of an object

   import { LightningElement, wire } from 'lwc';
   import { getListUi } from 'lightning/uiListApi';
   import ACCOUNT_OBJECT from '@salesforce/schema/Account';

   export default class Example extends LightningElement {
     @wire(getListUi, { objectApiName: ACCOUNT_OBJECT })
     propertyOrFunction;
   }

There is lot more examples in official documentation here

Note that the uiListAPI Module is implementation of the User Interface API thats documented here

2
  • With the above approach, We can only show 2000 records of any list view. Do we have any way to show list view records more than that i.e. without any limit Dec 16, 2020 at 4:48
  • 1
    It would be nice if the examples showed getting the fields that are specified in the list view. Instead they get a hard coded field to display. I think most people would want an example that shows dynamically displaying the fields as defined in the list view. Jun 3, 2021 at 13:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .