Last Updated on May 16, 2022 by Rakesh Gupta
Big Idea or Enduring Question:
How to convert listview filters for use in SOQL?
After reading this blog, you’ll be able to:
- Convert list view filters to equivalent SOQL
- Export records from list view to excel spreadsheet
- Understand the list views and list view describe call in REST API
- and much more
Business Use case
Arda Turan is working as a System Administrator at Gurukul on Cloud (GoC). He has received a requirement from his Sales director to export records from the Closing This Month opportunity list view to an excel sheet or CSV.
Guided Practice (We-do):
If you ever had such a requirement, then you understand the pain. Salesforce doesn’t support export list view results to excel sheets or CSV. It doesn’t mean that you have to rewrite the list view filters in the SOQL.
REST API List View Describe returns detailed information about a list view, including the ID, the columns, and the SOQL query.
Perform the steps below to export list view results to excel sheet:
Step 1: Find out the List View Id
First of all, we have to find out the list view id.
Step 2: Use REST Explorer to Find the List View Filters as SOQL
- Open the Workbench and log in with your Trailhead playground username and password.
- Make sure that you’ve selected the Production for Environment option.
- Navigate to Utilities tab and select the REST Explorer option.
- Select the following options:
- Check out the query in the response body.
- Use keyboard shortcuts to copy query to the clipboard.
- In the end, run the query to export the results to CSV file using the Workbench or Visual Studio Code.
Execute SOQL in Visual Studio Code
I want to hear from you!
What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? Feel free to share in the comments below.