Queries are very complex, yet powerful tools that help you access your data. The query editor is an intuitive interface that makes creating queries a lot simpler. This article explains how to use the query editor to create an
There are six basic steps to creating a query:
The query editor can be opened from any new expression rule, or any expression rule that contains a single
a!queryEntity() function. See Query Editor to learn more about what types of queries can be used with the query editor.
If you are editing an existing query, all of the configurable sections of the editor display. If you are creating a new query, only the Source Constant section displays.
The source constant defines which data store entity you want to query. In order to query a data store entity, you must first create a constant of type Data Store Entity that points to it. See Constants for additional information.
Once a constant is selected, the Query Results Preview section will display a preview of the data where you can view all of the fields in your data store entity.
If you want to use rule inputs for any of the settings in the query editor, you can create new rule inputs or edit existing ones directly from the query editor. You can use the query editor to change the test values of your rule inputs to test and troubleshoot your query.
The query editor allows you to select the paging and sorting parameters in Basic mode using configurable fields. You can set limits on the amount of rows you retrieve and determine the order of the rows with paging and sorting.
The default page size of the query is 50 rows per page and the default startIndex parameter is 1.
Select either In Ascending Order or In Descending Order.
If you need more advanced paging and sorting settings, select Expression to configure additional settings. For additional information on specifying paging and sorting as an expression, see
Filters allow you to select which results to return from your query based on conditions you specify. The query editor allows you to easily set up filters using four criteria: Field, Condition, Value, and Apply Filter.
If you want skip filters that have an empty value, select the Ignore Filters with Empty Values check box. See
a!queryLogicalExpression() for more information on ignoring filters with empty values.
Apply Filters is useful in situations where you want to apply the filter only if a particular condition is met. For example, if the user belongs to a specific group.
If you have more than one filter, use the up and down arrows to change the order in which the filters are applied. You can also delete a filter by clicking X.
If you need more advanced filters, select Expression to create your filters manually. See Query Recipes for a few examples of advanced filters.
Select Fields allows you to select which fields will be returned from your query. By default, the query editor fetches all fields so designers can see a query preview with all available fields. However, for performance reasons, it is a good practice to only query the fields that you need. If you query all of the fields, it may take longer for your query to run.
To configure the fields of your query:
You can preview the results of your query by clicking RUN QUERY. The results will display. If Fetch total row count is selected, a parameter will be applied to the query that will retrieve the total number of rows that are returned by the query.
Fetch total row count is applied to the query, not just the preview. If you have a lot of data, it is recommended to turn off Fetch total row count to improve performance.
The query preview only displays 10 rows at a time. This may differ from the number of rows per page in the Paging & Sorting section as it is only intended to be a preview.
If the query filters out all data, Query returned no data displays.