getListRecordsByName
Use this wire adapter to get record data for a list view.
| Parameter Name | Type | Description | Required? |
|---|---|---|---|
objectApiName | String | The API name of a supported object. | ![]() |
listViewApiName | String | The API name of a list view, such as AllAccounts. | ![]() |
fields | String[] | Additional fields queried for the records returned. These fields don’t create visible columns. If the field isn’t available to the user, an error occurs. | |
optionalFields | String[] | Additional fields queried for the records returned. These fields don’t create visible columns. If the field isn’t available to the user, no error occurs and the field isn’t included in the records. | |
pageSize | Integer | The number of list records viewed at one time. The default value is 50. Valid values are 1—2000. | |
searchTerm | String | A search term to filter the results. Wildcards are supported. | |
sortBy | String | The API name of the field the list view is sorted by. If the name is preceded with -, the sort order is descending. For example, Name sorts by name in ascending order, and -CreatedDate sorts by the created date in descending order. This parameter accepts only one value per request. | |
where | String | The filter applied to returned records, in GraphQL syntax. For example, { and: [ { StageName: { eq: "Prospecting" } }, { Account: { Name: { eq: "Dickenson plc" } } } ] } filters an Opportunity related list to show only opportunities in the Prospecting stage that are linked to the “Dickenson plc” account. | |
pageToken | Integer | A token that represents the page offset. To indicate where the page starts, use this value with the pageSize parameter. The maximum offset is 2000 and the default is 0. |
Read the data that’s returned by the wire adapter using a property or function.
propertyOrFunction—A private property or function that receives the stream of data from the wire service.
- If a property is decorated with
@wire, the results are returned to the property’sdataproperty orerrorproperty. - If a function is decorated with
@wire, the results are returned in an object with adataproperty and anerrorproperty.
data–List Record Collectionerror–FetchResponse
This code example fetches list view records by API name then iterates through the list of records.
The handleNextPage click handler returns the next set of record names.
The JavaScript code displays 10 records at one time. Initialize pageToken so the wire adapter has a defined value to start with. If any reactive config property is undefined, the wire service doesn’t provision data, and both data and error stay undefined. To handle pagination, use pageToken with the pageSize parameter. Get the next set of record names by assigning nextPageToken to pageToken. This value is incremented in steps of 10, as determined by the pageSize value.
If your component returns undefined data and undefined error, check that every reactive parameter (any value prefixed with $) has an initial value on the class. A $pageToken reactive parameter needs a pageToken = null; class property. Otherwise, the config is incomplete and the wire never fires.
Similarly, you can also handle backward pagination by using the previousPageToken property that’s returned by the getListRecordsByName wire adapter.
For more information, see List Record Collection.
See Also
