Skip to content

Query

The Query widget retrieves data from specified data sources and populates the data model with the results.

XML Fields

  • XPath establishes the current form-data context. TargetXPath identifies where selected query results are written.
  • AutoSearch runs the query when its monitored data sources change. ShowFilter controls whether the configured Filter controls are visible.
  • AutoSelectAll writes all returned rows without a selection dialog. ClearFirst clears the target before writing; otherwise new rows are appended.
  • ValidationGroup selects the validation group checked before a manual search.
  • Filter contains the input widgets used to collect query parameters. DataSources contains the sources that provide the result set. A data source can also define the result columns displayed in the selection dialog.
  • RowScript/Content is optional JavaScript run for each row that is being added. Rules holds conditional form behavior.

TargetXPath and RowScript are child elements, not attributes. Keep the target compatible with the shape of the result rows; clearing or appending affects that target only.

Data Model Mapping

The TargetXPath property determines where the query results are written in the data model.

  • Sequence Target: If the target XPath points to a sequence-type element, each row from the query results creates a new node within that sequence.
  • Single Node Target: If the target XPath points to a single node, the existing data at that location is cleared before the query results are written.

Filter Panel

A filter panel allows defining query parameters. These parameters are mapped to data model elements and passed to the data source to filter results.

  • AutoSearch: Controls whether the query executes automatically when filter values change (true) or requires manual execution via a search button (false).
  • ShowFilter: Controls the visibility of the filter panel. Set to false to hide the panel.

Result Selection

  • AutoSelectAll: If true, all query results are automatically added to the data model. If false, a modal dialog is displayed, allowing the user to select specific rows to add.

Data Clearing

  • ClearFirst: If true, the target data model element is cleared before populating with query results. If false, results are appended.

Rules Engine Integration

The Query widget supports rules:

  • Formatting Rules: When a formatting rule disables the widget, the widget is hidden, and the data model is not populated.
  • Validation Rules: Validation rules are executed when the search button is clicked. Failed validation prevents query execution and displays an error message.

Data Sources

The Query widget can utilize multiple data sources, combining results into a single result set. See Data Sources for details.

Result Column Templates

Result-column templates belong to the data source, not directly to the Query widget. For a TableDataSource, define the template in the source query's Columns/Column/Template element. The selection dialog evaluates that template for each result row before displaying the column.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
<DataSources>
    <TableDataSource TextFormat="{{Name}}" ValueFormat="{{Id}}" Enabled="True">
        <Mappings />
        <Query>
            <Parameters>
                <TargetSchema Type="System.String"><![CDATA[CRM]]></TargetSchema>
                <TargetTable Type="System.String"><![CDATA[Customer]]></TargetTable>
            </Parameters>
            <Columns>
                <Column Name="Id" />
                <Column Name="Name" />
                <Column Name="PhotoUrl">
                    <Template><![CDATA[<img height="50" src="{{PhotoUrl}}" alt="{{Name}}" />]]></Template>
                </Column>
            </Columns>
        </Query>
    </TableDataSource>
</DataSources>

In this example, the PhotoUrl column is rendered as an image in the Query result list. Treat template output as display content and use only values appropriate for the form's security context.

Row Scripting

A row script allows executing custom JavaScript code for each row in the query results. This script receives the current row ($Row) and the new child node to be added to the data model ($NewChild) as parameters.

Examples

Example 1: Basic Query

1
2
3
4
5
6
7
<Query XPath="" AutoSearch="False" AutoSelectAll="False" ShowFilter="True" ClearFirst="False" ValidationGroup="">
    <TargetXPath><![CDATA[List/User]]></TargetXPath>
    <Filter />
    <DataSources />
    <RowScript><Content><![CDATA[]]></Content></RowScript>
    <Rules />
</Query>

Example 2: Filter Panel

1
2
3
4
5
6
7
<Query XPath="" AutoSearch="False" AutoSelectAll="False" ShowFilter="True" ClearFirst="False" ValidationGroup="">
    <TargetXPath><![CDATA[List/User]]></TargetXPath>
    <Filter>...</Filter>
    <DataSources />
    <RowScript><Content><![CDATA[]]></Content></RowScript>
    <Rules />
</Query>