Table of Contents
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 Executor, 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.
SOQL Executor UI
The SOQL Executor operates with the custom split editor that contains three parts:
- for SOQL input — the upper one. Here you can write the code 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, and relationships,
- for a table with the results — the lower one.
Creating a SOQL query
The Welkin Suite offers you a handy way to create a new SOQL query. Follow these instructions:
- Create a new
.soqlfile using the Main Menu:
File ⇒ New ⇒ File ⇒ SOQL / Query, specify a name for it and click the New button. The created file will be opened automatically.
- 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
Selectstatement 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.
- 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.
In the Query Editor, you can add some conditions, aggregations or modify a query in any other way and execute it clicking the appropriate button at the top of the window. The keywords, strings, numbers in conditions, and aggregated functions are highlighted in a query code. The list of the keywords is the following:
- ORDER BY
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, which already has the
FROM %OBJECT_NAME% clause in it. Even in this way it is much faster to type in, for example,
SELECT FROM Account, place the cursor between the
FROM keywords and hit Cmd+Space or just start typing to get the full list of possible fields and functions to use.
After you executed the query, its results are immediately displayed in the lower part of the SOQL Executor. All the fields from look-ups and master objects are parsed by TWS SOQL executor and displayed in a convenient way in their own columns.
Aggregated functions are as well displayed in their own columns with proper headers, so you won't get lost in the 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.
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 new list of the child items will be opened in an additional pane in the same window.
You can also search for a necessary data using the search field above the query results.
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 by double-clicking the particular cell.
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, so you can check the reason for a fail and quickly revise your query.
In this section:
This also may be useful: