SOQL Query Builder and Data Editor

The SOQL Query Builder and Data Editor is a great helper in creating, debugging, or optimizing the code. It gives you the ability to learn about the results of a complex query before putting such a query in the code.

SOQL is created for searching specific information within Salesforce data of your organization. It can be used in Apex statements as well as in Visualforce controllers and getter methods.

In the SOQL Query Builder and Data Editor, you can run complex query strings and immediately get a response with the specified objects from the Salesforce org. This ability is helpful in different situations such as:

  • quickly find strange / broken data in one query without having to write the code,
  • spend less time when testing a complicated query with multiple subqueries and being able to fix it faster with the help of the error logs,
  • avoid SOQL governor limits while estimating the amount of data for a query directly in IDE,
  • optimize queries or check the query velocity without building and having to spend a long time testing,
  • modify records in the org to match some criteria of the logic that is being developed — to ensure that everything works as intended,
  • correct records directly in the org instead of searching for the correct page layouts, and / or search for where the needed fields are available and editable.

SOQL Query Builder and Data Editor UI

The SOQL Query Builder and Data Editor operates with the custom split editor that contains three parts:

  • for SOQL input — the upper one. Here you can write a query and execute it with the help of the Execute SOQL button,
  • for Schema Explorer — the right one. Here you can select necessary objects, their fields (including sObjects and fields from installed managed packages), and relationships,
  • for a table with the results — the lower one.

SOQL Executor

Creating a SOQL query

The Welkin Suite offers you a handy way to create a new SOQL query. Follow these instructions:

  1. Create a new .soql file using the Adding new Items feature in the context menu of the Solution Explorer or the Create SOQL File option from the context menu of an object file in the Code Editor or in the Solution Explorer. The newly created file will be opened automatically.
  2. Use the Schema Explorer for creating your query: expand the necessary object and check the box next to the needed fields and child relations. They will be automatically added to the Select statement in the query editor. In addition, the automatically added items are formatted in the nice and readable way, so the query structure is clearly seen immediately. As a side note, you can use the Search Schema Explorer filter for easier navigation.
  3. Click on the Execute SOQL button. The Welkin Suite will show you the results in the lower part of the SOQL Executer according to your query.
NB: The SOQL file isn't built on your org, it is saved only locally.

You can also execute only some lines from the query. For this purpose, use the Execute highlighted button.

In the Query Editor, you can add some conditions, aggregations or modify a query in any other way. The keywords, strings, numbers in conditions, and aggregated functions are highlighted in a query code. The list of the keywords is the following:

  • FROM
  • DESC
  • ASC
NB: If you modify a query in the editor, for instance, delete some relationships, these changes are not displayed in the Schema Explorer — the child relationships still will be checked.

Query Completion in Apex

The IDE suggests to you a list of possible fields and aggregate functions when you type in the SOQL query. Inside the square braces, you should have the SELECT keyword as well as the FROM clause with a name of a sObject to retrieve a data from. Then place your cursor between the SELECT and FROM keywords and start typing or just press the Ctrl+Space hotkey. This will bring you a list of completions with:

  • standard fields from the given object,
  • custom fields from the given object,
  • applicable functions, that might be used in SOQL queries.

Query Completion in Apex

Query results

After you executed the query, its results are immediately displayed in the lower part of the SOQL Query Builder and Data Editor. All the fields from look-ups and master objects are parsed by TWS SOQL Query Builder and Data Editor and displayed in a convenient way in their own columns.

The subqueries are displayed as related lists in their turn in the appropriate result column with a count of their child items shown right there. You can open the results for your sub-select clicking on it and the sub-select will be expanded.

Query results

There is a limitation of the amount of data which Salesforce returns on a query. Click on the Get more button and the next bunch of data will be downloaded. In cases when a result set contains a huge amount of data it can be split into several pages showing 500 rows per page.

Additional options

For quick modifying records in the org, just double-click on any editable field in the query results table and you will be able to edit the value. The IDE will highlight cells with changed values with a different background color, so if you are changing multiple fields or multiple records (or both) you won't forget what you've changed.

SOQL Data Editor

To get a bit more information about fields, just hover the cursor over any cell and you'll see details, such as:

  • object type,
  • field type,
  • if the field value can be set to Null or no.

In the case a field is not editable, the IDE will highlight this in a hint.

SOQL Editor hint

Additionally, you can call a context menu for any value with the following options:

  • Copy — copies value of the selected cell to the clipboard,
  • Set the value for the whole column — applies the value from the selected cell to all records, that are visible in the results (for the same field),
  • Set value to Null — sets the value of the selected field to Null,
  • Set original value — if you've done any changes to the value in the selected cell, this option will revert it back to the original value, retrieved by the SOQL query.

Quick actions

Once you're done with your changes, just press the Upload changes button in the upper part of the SOQL Builder and the IDE will try to apply them.

NB: The Welkin Suite does not re-execute the query once more, so if you need to get the real values from the org afterward, you'll need to re-execute the SOQL query one more time.

If you need to save a query result, click on the Export to CSV. This applies as for all those entries, that you've loaded during clicking Get more button, so for a separate subquery result also. Additionally, you can copy any value from results using the context menu of the particular cell or by double-clicking it.

In addition, you can copy the data from SOQL query results. Just select the necessary cells, click the right mouse button, and choose the Copy option. TWS provides you with an option to copy the following sets of data:

  • one or more separate cells;
  • entire spreadsheet;
  • one or more columns;
  • one or more rows.

Errors in a query

The Welkin Suite handles all the errors when running a SOQL query. Execution errors are displayed in the Error List Panel with a line number of an error, so you can check the reason for a fail and quickly revise your query.

SOQL Executor error list

In this section:

This also may be useful:

Last modified: 2018/01/31 15:38

footer image