NAVIGATING TO
LISTVIEW IN LWC
(LIGHTNING WEB
COMPONENT)
@TrailheadIQ
Navigating to ListView in LWC
A ListView in Salesforce allows you to display
filtered records (e.g., Accounts, Contacts,
Opportunities) based on certain criteria.
Users can quickly view a subset of records
without navigating into individual record pages.
Examples of ListViews:
All Accounts
Recently Viewed Contacts
Opportunities Closing This Month
@TrailheadIQ
Why Navigate to ListViews from
LWC?
Easy Access to Records: Quickly direct users to
specific record groups, such as recently modified
or open records.
Improved Workflow: Streamline navigation by
letting users view important records without
manual clicks.
Customizable Filters: Guide users to custom List
Views with specific criteria, enhancing their
experience.
@TrailheadIQ
How to Navigate to a List View Using
NavigationMixin
To navigate to a specific List View in Salesforce, we use
NavigationMixin. Here's how you can implement it in
your LWC.
Import NavigationMixin and extend your class with
NavigationMixin:
@TrailheadIQ
Create a method to navigate to a
List View
@TrailheadIQ
🔍 Understanding the Code
type: 'standard__objectPage': This tells
Salesforce you want to navigate to an object’s list
view.
attributes: { objectApiName, actionName }
objectApiName: Specifies the object you are
navigating to (e.g., Opportunity, Contact).
actionName: Specifies the action, which in
this case is 'list' (to navigate to the list view of
that object).
@TrailheadIQ
🔍 Understanding the Code
state: { filterName }
filterName: Defines the API name of the list
view to display. Some default options are:
'Recent': Shows the Recently Viewed
records for the object.
Custom List Views can also be navigated
to by providing the API name of the list
view.
@TrailheadIQ
Real-World Use Case Example
Let’s say you want to navigate the user to a custom
list view named "Open Opportunities" after a new
Opportunity is created.
➡️ In Practice: This example demonstrates automatic
navigation to the "Open Opportunities" list after a
new Opportunity is successfully created.
@TrailheadIQ
Navigating to Default and
Custom List Views
Default List Views:
Recently Viewed: 'filterName: Recent'
Use this for navigation to the list of recently
viewed records.
💡 Custom List Views:
To navigate to a custom list view, you must provide
the API name of the custom view.
🔑 Pro Tip: Use Salesforce Developer Console to
query List View API names for custom views.
@TrailheadIQ
Best Practices for Navigating to
List Views
Ensure Access: Ensure that the user has access to
the object and list view you’re navigating them to.
Use Relevant Filters: Navigate to specific list
views based on the user's current needs or recent
actions.
Dynamic Navigation: Pass dynamic values like
the object name and list view name to make your
component flexible across objects.
@TrailheadIQ
🚀 Conclusion
Navigating to List Views in Salesforce using
NavigationMixin allows you to enhance user
experience by directing them to the right records
at the right time.
Whether it's a default list like Recently Viewed or
a custom one like My Open Cases, you can guide
users to the views that matter most to them.
@TrailheadIQ
THANK
YOU
Remember, every like, share, and comment
helps us reach more people and make a
bigger impact. Together, we can make the
Salesforce community stronger and more
informed.#TrailheadIQ#SalesforceCommunity
www.trailheadiq.com