Pages

Thursday, January 7, 2021

Salesforce: Export Query Result from Developer Console

In case you have no access to the workbench, can we download the query result from the Developer Console?


Build a Query in Developer Console

Open Developer Console, File > Open > Objects > select an object > click Open (or double click the object name). 


Select the fields by hold the Ctrl key (and Shift key) for Windows users, then hit the Query button, Id field will be auto-added.

Click the Execute button, developer console will open a tab with the query result.



Export query result to Excel file

This is tested in Chrome and chromium-based web engines (such as Edge and Opera), so not sure for Firefox and Safari.

Right-click on the query result and select Inspect.


Look for the table tag, then do "Copy element".


Open Excel and Paste to get the result.




 

15 comments:

  1. Thank you but the "Copy element" doesn't work because when I tried to Paste it into Excel, it includes the HTML tags. None of the other Copy/Paste options worked. Could you please clarify the Excel version and the exact Paste option you're choosing. I ended up doing the query in the Workbench and exporting as CSV but I may not always have access to the workbench, so this could be very helpful to someone. I hope Salesforce will add this functionality out of the box someday.

    ReplyDelete
    Replies
    1. I just try and it works, it is simply a copy and paste.
      I am using Microsoft Excel version 2102 (Build 13801)

      Delete
  2. It took me a good 15 tries (and because I am stubborn, I kept doing it over and over and over again). I honestly don't know what I did differently the last time because, come on, this is copy and paste. But it didn't work the first bunch of times.

    ReplyDelete
    Replies
    1. assume you manage to get it works!

      Delete
    2. I did. Thank you for this information. Very helpful.

      Delete
    3. awesome, glad to hear it 😊

      Delete
  3. Johan, this article was very helpful for me and your outlined solution worked for me.
    Thank You!

    ReplyDelete
  4. Is it just me or does it only grab the first 2,000 records?

    ReplyDelete
    Replies
    1. I am not sure how to get more 2K in Developer Console query editor, but you can use workbench to get all records https://workbench.developerforce.com/login.php

      Delete
  5. Use workbench application and download it as excel.

    ReplyDelete
  6. Thank you for posting this. Works perfectly.

    ReplyDelete
  7. NOTE: when pasting into Excel, use Paste Special > Unicode Text. This handles the xml and provides the desired result.

    ReplyDelete
  8. This is a great hack, but I recommend you edit/caution users at the start of the article that this method only works for SOQL queries that are less than 2,000 rows.

    The query will display the correct count of returned rows (at the top of the selection results), but it will only display the first 2000 rows. This is similar to standard salesforce reports: they warn you that they can only display 2,000 records to the browser, but the report itself will export all the rows when the export option is selected.

    Great hack, but use it carefully, and only for small data sets (under 2000 rows).

    ReplyDelete