Sub topic 5
Working with list views
This chapter assumes you know what an object, a record, and a field are, and that you can open the Accounts tab in a Salesforce org. It covers what a list view is, how it maps to a query, how to read the controls on it, and the errors people hit most often. The next chapter covers creating and filtering views in detail, and the one after covers display modes and inline editing.
What a list view is
A list view is a saved definition that shows a set of records of one object. Each list view stores three things:
- Filters that decide which records appear.
- Columns that decide which fields are shown.
- A sort order that decides the row order.
A list view does not copy data. Each time you open it, Salesforce runs the definition against the current data and shows the result. If another user edits a record, your view reflects that change the next time it loads or refreshes.
You reach a list view from the object's tab, which is the object home page covered in the previous chapter. For Accounts, the object home page opens the last list view you used.
The list view as a query
A list view behaves like a SOQL query, the query language Salesforce uses to read records. Suppose a view is named "Technology Accounts". It filters Accounts by Industry and sorts by Name. It returns the same rows as this query:
SELECT Id, Name, Industry
FROM Account
WHERE Industry = 'Technology'
ORDER BY NameEach part of the view maps to a part of the query:
| List view setting | SOQL equivalent |
|---|---|
| Selected columns | Fields in the `SELECT` list |
| Filter by Owner (All, My, or a queue) | A condition on `OwnerId` |
| Filter by fields | Conditions in `WHERE` |
| Sort | `ORDER BY` |
The mapping is a way to think about views. You do not write SOQL to build a list view. The query also adds Id and some display fields behind the scenes, so the columns you see may differ slightly from the SELECT list above.
This model explains most surprises. If a record is missing, a filter or your access excluded it. If rows appear in an odd order, the sort field or its values are the cause.
Anatomy of the list view page
The page has four areas worth knowing.
- The title area. It shows the object name and the current view name. The name is a drop-down that opens the list of views for the object.
- The pin control. It marks one view as the default for that object and for you.
- The toolbar. It holds the search box for the view, the display-mode switch, the settings (gear) menu, the refresh button, and the filter button.
- The table. It shows the columns, one row per record, with a sort arrow on the active sort column.
The gear menu is where most management actions live. It includes options to create a new view, rename a view, edit sharing settings, select the fields to display, and restore a view to its original state. Which options appear depends on the view and on your permissions.
Standard views and your own views
Every object that has a tab comes with some standard list views. Accounts typically include "All Accounts", "My Accounts", "New Last Week", "New This Week", and "Recently Viewed". Some views, such as "Recently Viewed", are system views that Salesforce maintains, and you cannot change their filters.
You can also create your own views. A view you create is private to you by default. You can share it with a group, a role, or all users, if your admin allows that. Administrators and users with the right permission can edit shared views.
Keep these points in mind when you choose between views:
- "Recently Viewed" shows records you opened recently. It is not a filter on a date field of the record.
- "All" views show every record you can see, not every record in the org. Sharing rules and permissions still apply.
- A shared view shows the same filters to everyone, but each person sees only the records they have access to. Two users can open the same view and see different row counts.
Searching within a list view
The search box in the toolbar searches only the records the current view returns. It does not search the whole object. If you search for "Acme" in "My Accounts" and the Acme account is owned by someone else, nothing is found.
When a search finds nothing, check the view before you assume the record does not exist. Switch to an "All" view, or use global search, which is covered in a later chapter.
Sorting and column behavior
Click a column header to sort by that column. Click it again to reverse the order. The sort applies to the whole result set, not just the rows on screen.
A few details matter:
- You can sort by only one column at a time through the column header.
- Some field types cannot be sorted, such as long text areas and certain multi-select fields. Their headers show no sort arrow.
- Sorting by a picklist (a field with a fixed list of values) follows the order of the picklist values, which may not be alphabetical.
- Records with an empty value in the sort field group at the start or the end, depending on the direction.
The list shows a limited number of rows at first and loads more as you scroll. Scrolling to the bottom loads the next batch. A view can contain thousands of records, so do not rely on scrolling to find one record. Use the view's search box or tighten a filter instead.
Reading a list view URL
Each list view has an address. In Lightning Experience, the list view for Account named Recent and the page of a single Account look like this:
/lightning/o/Account/list?filterName=Recent
/lightning/r/Account/001XXXXXXXXXXXXXXX/viewThe first path opens the list view. The o stands for object, and filterName names the view. For a standard view the value is a name such as Recent. For a custom view it is the view's 15 or 18 character Id. The second path opens one record, and 001XXXXXXXXXXXXXXX stands for a real record Id. A later chapter covers these patterns in full. For now, the useful point is that you can bookmark or share a link to a specific view.
Common errors and how to diagnose them
| Symptom | Likely cause | What to check |
|---|---|---|
| A record you expect is missing | A filter excludes it, or you cannot see it | Open the filter panel and read every condition. Check the owner filter. |
| A colleague sees different rows in the same view | Sharing and permissions differ | Compare their access to the records, not the view definition. |
| Your changes to a view are not saved | The view is a system view, or you lack permission | Create a copy under a new name instead. |
| Search finds nothing | Search is limited to the current view | Switch to an "All" view or use global search. |
| A column is missing | The field is not selected, or you cannot see the field | Use the gear menu to select the fields to display. Check field-level security. |
| The view opens on a different list than you expect | A different view is pinned | Pin the one you want. |
Field-level security is the setting that controls which fields a profile or permission set can see. If you lack access to a field, it does not appear as a column option at all.
Edge cases
- Limits on the displayed rows. A list view shows only a limited number of records at a time and loads more as you scroll. Very large result sets also slow down. If a view feels slow, add a filter that narrows the result.
- Filter changes on a view you do not own. You can adjust the filter panel temporarily on some views, but the change is not saved unless you can edit the view. Reloading the page returns it to the saved filters.
- Deleted records. A deleted record leaves the view at once. It moves to the Recycle Bin and no longer matches any view.
- Renamed or deleted views. Deleting a view breaks bookmarks that use its Id. Renaming a view does not break them, because the link uses the Id and not the name.
- Object without a tab. An object can have list views only if it is available through a tab or another navigation item in your app. If the object is not in your app, find it through the App Launcher.
Opening a list view from code
Developers can send users to the same list view from a Lightning Web Component. The NavigationMixin takes a page reference, which is an object that describes the destination. The component below opens the Account Recent view and a specific Account record:
import { LightningElement } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
export default class AccountNavigator extends NavigationMixin(LightningElement) {
openRecentAccounts() {
this[NavigationMixin.Navigate]({
type: 'standard__objectPage',
attributes: {
objectApiName: 'Account',
actionName: 'list'
},
state: {
filterName: 'Recent'
}
});
}
openAccount(recordId) {
this[NavigationMixin.Navigate]({
type: 'standard__recordPage',
attributes: {
recordId: recordId,
objectApiName: 'Account',
actionName: 'view'
}
});
}
}The state.filterName value plays the same role as the filterName query parameter in the URL. This is why reading URLs helps you write navigation code. A later chapter covers the mixin in more detail.
Summary of practical habits
- Read the view name before you trust the row count.
- Check the filters first when a record is missing.
- Treat the search box in a list view as a filter on that view only.
- Pin the view you use most.
- Copy a system or shared view before you change it.
Exercise
A colleague tells you the account "Northwind" does not exist because they searched for it in the "My Accounts" view and found nothing. Give two reasons the record may still exist, and say where you would look next.
Show answer
The search box only searches the rows the current view returns, and "My Accounts" shows only accounts you own, so Northwind may be owned by someone else. The record may also be excluded by another filter on the view. Switch to an "All Accounts" view and search again, or use global search.
Exercise
A view named "Technology Accounts" filters Account by Industry equals Technology and sorts by Name. Write the SOQL query that returns the same rows, selecting Id, Name, and Industry.
Show answer
SELECT Id, Name, Industry FROM Account WHERE Industry = 'Technology' ORDER BY Name
Exercise
In the URL /lightning/o/Account/list?filterName=Recent, what does each of the parts "o", "Account", "list", and "filterName" identify?
Show answer
"o" marks an object page, "Account" is the object, "list" is the action that shows a list view, and "filterName" names the list view to open (here the standard view Recent).