Skip to main content
Version: 1.28 (Current)

Get Data Query

Audience: Low-code Engineers

Skill Prerequisites: Actions, Listings, SQL

Stores the query behind a Listing's data source in tokens, together with the filters the user has applied. Use it to see what data the Listing is showing, for example to log it or reuse the filters in later actions.

It runs in Listing button actions and uses the search, filters and sorting sent with the button click. What the tokens contain depends on the data source type.

Typical Use Cases​

  • Debug a Listing by logging the exact query it runs
  • Save the filters a user applied, for example with an export or a report request
  • Reuse the Listing's filter clause in your own SQL, when the data source is a Database Table

Don't use it to​

  • Get the rows themselves. Use the built-in ActionGridEntry list on root buttons, or Run SQL Query.
  • Change the Listing's filters. Use Filter Listing instead.
Action NameDescription
Run SQL QueryRuns SQL, for example to store the captured query or filters.
Filter ListingChanges the sorting, paging and filters of a Listing.
Log ErrorWrites a message, such as the captured query, to the log.

Input Parameter Reference​

Leave a parameter empty to skip that token.

ParameterDescriptionSupports TokensDefaultRequired
Store Query in TokenName of the token that gets the data source's query, without the user's filters, for example DataQuery.Noempty stringNo
Store Filters in TokenName of the token that gets the filters, such as search and column filters, for example DataFilters.Noempty stringNo
Store Filtered Query in TokenName of the token that gets the query with the user's filters applied, for example FilteredQuery.Noempty stringNo

Output Parameters Reference​

TokenDescription
[<Store Query in Token>]The data source's query.
[<Store Filters in Token>]The current filters.
[<Store Filtered Query in Token>]The query with the filters.

What the tokens contain​

Data sourceQueryFiltersFiltered Query
Database TableThe start of a WITH Results AS (SELECT ..., ROW_NUMBER() OVER (ORDER BY ...) ... statement over the table. The ORDER BY follows the current sort.A WHERE clause built from the filters, or empty when there are none.The query plus the WHERE clause and the closing bracket. Add SELECT * FROM Results to run it. It isn't limited to the current page.
SQL Advanced QueryThe data source's SQL query, with tokens replaced.The filter expression. It isn't SQL. The Listing applies it in memory after running the query.The query followed by -- filtered at runtime with: and the filters. The filters are only a comment.
Action Form (Obsolete)The search index query.The same search index query.The search index query and the sort.
Other data sources, such as SQL Select or Server Request (JSON)Empty.Empty.Empty.

Considerations​

  • Listing buttons only. The action needs a Listing's context. It fails with Data source not configured when the Listing has no data source.
  • It may load the data. If the Listing's data hasn't been loaded in the current request, the action loads it first, so the data source's query runs.
  • Not always runnable. Only the Database Table filtered query can be run as SQL. For SQL Advanced Query, filtering happens in memory, so the filtered query doesn't reflect the filters.
  • Pass values safely. When you save a captured query or filters with Run SQL Query, pass them as bound parameters instead of pasting the token into the SQL.
  • Doesn't stop execution. The next actions run normally.

Examples​

tip

To understand how to use the below examples, please see Running Examples.

1. Capture the Listing's query and filters​

This action stores the query in [DataQuery], the filters in [DataFilters] and the filtered query in [FilteredQuery].

{
"Title": "Get Data Query",
"ActionType": "GetDataQuery",
"Description": "Capture the Listing's query and filters",
"Parameters": {
"OutputTokenNameQuery": "DataQuery",
"OutputTokenNameFilters": "DataFilters",
"OutputTokenNameFilteredQuery": "FilteredQuery"
}
}

2. Save the filters with an export request​

Add this action after the one in example 1, on the same root button. It records who requested the export and which filters were applied.

{
"Title": "Run SQL Query",
"ActionType": "RunSql",
"Description": "Save the export request",
"Parameters": {
"SqlQuery": "INSERT INTO ExportRequests (UserId, Filters, RequestedOn) VALUES (@UserId, @Filters, GETDATE())",
"BindTokens": [
{ "name": "UserId", "value": "[User:UserId]" },
{ "name": "Filters", "value": "[DataFilters]" }
]
}
}

Revised 09/26/2026