Easiest Way to Convert ListView Filters for use in SOQL

Easiest Way to Convert ListView Filters for use in SOQL

Last Updated on August 14, 2023 by Rakesh Gupta

Big Idea or Enduring Question:

  • How to convert listview filters for use in SOQL? 

Objectives:

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.

  1. Select the List view i.e. Closing This Month
  2. Grab the ID from URL

Step 2: Use REST Explorer to Find the List View Filters as SOQL

  1. Open the Workbench and log in with your Trailhead playground username and password.
  2. Make sure that you’ve selected the Production for Environment option.
  3. Navigate to Utilities tab and select the REST Explorer option.
  4. Select the following options:
    1. Choose an HTTP method to perform on the REST API service URI below: GET
    2. URL: /services/data/v53.0/sobjects/Opportunity/listviews/00B2E00000AchVZUAZ/describe
    3. Click Execute.
  5. Check out the query in the response body.
  6. Use keyboard shortcuts to copy query to the clipboard. 
  7. 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

👉 Check out the video for step-by-step instructions.

Formative Assessment:

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.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!
Preferred Timing(required)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.