Skip to content

Export Query – turning the result of a query into file content

The command "Export Query" runs a query and writes the records as CSV, JSON, XML or Excel content into a variable. This page is for administrators who build exports, reports sent by mail or data transfers to other systems.


1. At a glance

Purpose Export the records of a query in a file format
Typical use Mail a weekly Excel list; store an export with a record; send data to another system
Where in the editor Toolbar menu "Data" → "Export Query"
Needs a user interface No
Related Add File, Send E-Mail, Write To File, HTTP Request

The command only fills a variable. It does not store, download or send anything. Follow it with the command that uses the content.


2. Settings

The settings are on the tab "Settings". "Display Name", "Description" and "Execution Condition" are on the tab "General" (see Actions).

Setting Meaning Default / Required
"Query" The query whose records are exported (see Queries) Required
"Grid" A grid of the entity of the query. Its field columns become the columns of the export, in the order of the grid. Offered once a query is chosen. Empty: all fields of the entity
"Output Format" CSV, JSON, XML or XLSX CSV
"Output Variable" The variable the content is written into Required

3. Behaviour

  1. Without a query, or if the query no longer exists, the command is skipped.
  2. The query is evaluated against the current record (if there is one) and the variables, and keeps its sorting.
  3. The read restrictions of the user who runs the action apply. An export never contains records that this user could not see.
  4. The columns are the fields of the grid or, without a grid, all fields of the entity. The column headings are the display names of the fields.
  5. The content is written into "Output Variable". If the query fails, the variable is set to empty and the reason is written to the log.

Formats

Format Content of the variable
CSV Text with a header row, comma separated
JSON Text: an array with one object per record; the property names are the column headings
XML Text: a root element Records with one Record element per record; the element names are the column headings, adjusted where a heading is not a valid XML name
XLSX An Excel workbook, base64 encoded – ready for Add File, Write To File with "Decode Base64", or the attachments of Send E-Mail

The values are exported as they are stored. In Excel, a value longer than 32,767 characters – the limit of a cell – is shortened and ends with ...; the other formats keep it whole.

Columns of a grid

Only grid columns that show a field of the queried entity are exported. Columns that show a field of a related entity, and badge, HTML or toolbar columns, are left out.


4. Examples

Store a monthly Excel export with a report.

  1. "Export Query" with "Query" Open orders, "Grid" Orders – export, "Output Format" XLSX, "Output Variable" Export.
  2. Add File with "Base64 Data" Export and the file name open-orders.xlsx.

Hand a CSV file to another system. "Export Query" with CSV into CsvText, then Write To File with "Contents" CsvText into the exchange folder. For Add File, CSV, JSON and XML must be base64 encoded first (rule EncodeBase64).


5. Limitations

  • The CSV separator is always a comma; the Excel workbook has one worksheet without formatting.
  • Values are exported in their stored form – for example the key of a value list rather than its display text.
  • Fields of related entities cannot be exported with this command.
  • The whole export is held in memory as text. Very large queries make the action slow.