> For the complete documentation index, see [llms.txt](https://docs.valorx.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.valorx.com/valorx-fusion/design-studio/tasks/query.md).

# Query

A Query Task builds the relationship between Maps and Data Modelling. It retrieves records from an object, either in the background or by letting the user filter and choose records at runtime.

## Create a Query Task

{% stepper %}
{% step %}
Click Task, then click New Query Task.
{% endstep %}

{% step %}
Choose a Mode, then set the object, name and fields.
{% endstep %}

{% step %}
Optionally click Add Filter(s) to add filters.
{% endstep %}

{% step %}
Click Save.
{% endstep %}
{% endstepper %}

<figure><img src="https://2472585788-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFqFFf4143HS0_Wagnz%2Fuploads%2FLaPaTFNygua5K9J33XyN%2FCreate%20A%20Query%20Task.gif?alt=media&amp;token=ba460937-83d2-44c0-9b9a-d2afb64988c8" alt=""><figcaption></figcaption></figure>

## Modes

<table><thead><tr><th width="153.44442749023438" valign="top">Mode</th><th valign="top">At runtime</th></tr></thead><tbody><tr><td valign="top">Standard</td><td valign="top">The user doesn't see or do anything. The task runs automatically in the background during Runtime.</td></tr><tr><td valign="top">User Selection (Full)</td><td valign="top">Opens the <a href="https://docs.valorx.com/valorx-fusion/runtime/runtime-ux/search-and-select.md">Search and Select</a> screen with a list of records. The user filters and chooses the records to retrieve.</td></tr><tr><td valign="top">User Selection (Compact)</td><td valign="top">Opens the <a href="https://docs.valorx.com/valorx-fusion/runtime/runtime-ux/search-and-select.md">Search and Select</a> screen with filters only. The user can't choose records; every record that matches the filters is retrieved.</td></tr></tbody></table>

<figure><img src="https://2472585788-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFqFFf4143HS0_Wagnz%2Fuploads%2FCxFznPyb02wHi35XJi9t%2FQuery%20Task%20Mode.gif?alt=media&amp;token=b08785ce-5fad-4723-8338-f347ff422e08" alt=""><figcaption><p>Mode Options</p></figcaption></figure>

### Query Task settings

<table data-search="false"><thead><tr><th width="227.88885498046875" valign="top">Setting</th><th valign="top">What it does</th></tr></thead><tbody><tr><td valign="top">Object Name</td><td valign="top">The object to query, for example <em>Account</em>.</td></tr><tr><td valign="top">Name</td><td valign="top">The task name. In User Selection modes it's also the Search and Select screen title.</td></tr><tr><td valign="top">Max Records By / Max Records</td><td valign="top">How many records load into the list. Multi Select: 500 by default, can be changed. Single Select: fixed at 500, field disabled.</td></tr><tr><td valign="top">Sort By</td><td valign="top">The order of records in the list.</td></tr><tr><td valign="top">Add Header Subtext</td><td valign="top">Adds a line of text under the Search and Select screen title. Once set, the link reads Edit Header Subtext.</td></tr><tr><td valign="top">Record Selection Type (Full only)</td><td valign="top"><strong>Single Select</strong> lets the user pick one record, and Max Records is fixed at 500. <strong>Multi Select</strong> lets them pick several, or every matching record. See <a href="https://docs.valorx.com/valorx-fusion/runtime/runtime-ux/search-and-select.md#single-select-vs-multi-select">how each option works at runtime</a>.</td></tr><tr><td valign="top">Allow to change search field operator at Runtime (Full only)</td><td valign="top">Lets the user change a filter's operator on the Search and Select screen.</td></tr><tr><td valign="top">Preview (Full only)</td><td valign="top">Opens the Search and Select screen in Preview only mode to check the setup before saving.</td></tr><tr><td valign="top">Add fields / Add Related Field</td><td valign="top">Add fields from the object or a related object to the field list.</td></tr><tr><td valign="top">Add Filter(s)</td><td valign="top">Adds fixed filters that always apply to the query. The runtime user doesn't see or change them. See Filters.</td></tr></tbody></table>

<figure><img src="https://2472585788-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFqFFf4143HS0_Wagnz%2Fuploads%2FRMEH5GOdFIicZZUxNlHe%2FStandard%20v2.png?alt=media&amp;token=4d0d12b4-b8a0-43e2-b141-21f0e9bb8ef1" alt=""><figcaption><p>Standard</p></figcaption></figure>

<figure><img src="https://2472585788-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFqFFf4143HS0_Wagnz%2Fuploads%2FfRn7Ny74LzSi53nddCp4%2FUser%20Selection%20(Full).png?alt=media&amp;token=9f91427d-09ab-4ff5-b829-45a91b26553f" alt=""><figcaption><p>User Selection (Full)</p></figcaption></figure>

<figure><img src="https://2472585788-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFqFFf4143HS0_Wagnz%2Fuploads%2FU0qfygNdcpKKBMrrVKCq%2FUser%20Selection%20(Compact).png?alt=media&amp;token=bc1b9fe3-8210-4ac8-a020-a89868fd30f2" alt=""><figcaption><p>User Selection (Compact)</p></figcaption></figure>

## Filters

Filters work in every mode and always apply to the query.

* **Standard**: The Filters panel shows Add Filter and Add Cross Filter directly.
* **User Selection (Full) and User Selection (Compact)**: Click Add Filter(s) at the bottom of the dialog to open the filters. A badge on the button shows how many filters are set.

In User Selection modes, these filters run in the background and aren't shown on the Search and Select screen.

<figure><img src="https://2472585788-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFqFFf4143HS0_Wagnz%2Fuploads%2FJx2zCUZmGr0BKqpQiQdj%2Fimage.png?alt=media&amp;token=9b0a12bd-f4f5-4a38-bfbc-93871219dd08" alt=""><figcaption></figcaption></figure>

### Add a Filter

{% stepper %}
{% step %}
Click Add Filter. The Select a Field window opens, listing the fields of the query object.
{% endstep %}

{% step %}
Find the field, using Search Fields if needed, and click it.
{% endstep %}

{% step %}
Set the condition in the new filter row.
{% endstep %}
{% endstepper %}

<figure><img src="https://2472585788-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFqFFf4143HS0_Wagnz%2Fuploads%2FOtY2t5TO6F4xZoSFWvPb%2FQuery%20Filter.gif?alt=media&amp;token=ba9ab85b-ce25-4cea-8af4-aa14dd7be200" alt=""><figcaption><p>Filter</p></figcaption></figure>

<table><thead><tr><th width="181.22219848632812" valign="top">Filter Row Field</th><th valign="top">What it does</th></tr></thead><tbody><tr><td valign="top">Field Name</td><td valign="top">The field you picked.</td></tr><tr><td valign="top">Filter</td><td valign="top">The operator, for example <em>Equal</em>. See Operators by data type.</td></tr><tr><td valign="top">Filter Type</td><td valign="top">Where the value comes from. See <a href="#filter-type-options">Filter Type</a> options below.</td></tr><tr><td valign="top">Value</td><td valign="top">The value to compare against, for example <em>(Is Blank)</em>.</td></tr></tbody></table>

Each filter is numbered. Click the remove icon at the end of a row to delete it.

#### Filter Type Options

<table><thead><tr><th valign="top">Filter Type</th><th valign="top">Value comes from</th></tr></thead><tbody><tr><td valign="top">Constant Value</td><td valign="top">A fixed value you enter.</td></tr><tr><td valign="top">Excel Reference</td><td valign="top">A cell in the workbook.</td></tr><tr><td valign="top">Named Range Reference</td><td valign="top">An Excel named range.</td></tr><tr><td valign="top">Session Variables</td><td valign="top">A session variable.</td></tr></tbody></table>

### Add a Cross Filter

A cross filter refines results based on related records. For example, an *Account* query can return only accounts whose related *Opportunities* match a condition. This gives more precise results for complex data relationships without affecting performance.

{% stepper %}
{% step %}
Click Add Cross Filter. The Select a Field window opens.
{% endstep %}

{% step %}
Choose the related object in Child Relationship, for example *Opportunity*.
{% endstep %}

{% step %}
Find the field on that object and click it.
{% endstep %}

{% step %}
Set the condition in the new filter row.
{% endstep %}
{% endstepper %}

<figure><img src="https://2472585788-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFqFFf4143HS0_Wagnz%2Fuploads%2FShC3kJUSwWZMjpuC29b3%2FQuery%20Cross%20Filter.gif?alt=media&amp;token=49fa03a4-e699-4698-870e-cc0aa625c787" alt=""><figcaption><p>Cross Filter</p></figcaption></figure>

<table data-search="false"><thead><tr><th width="209" valign="top">Cross Filter Row Field</th><th valign="top">What it does</th></tr></thead><tbody><tr><td valign="top">Child Relationship</td><td valign="top">The related object, set in the Select a Field window.</td></tr><tr><td valign="top">Child Relationship Field</td><td valign="top">The field that links the related object to the query object, for example <em>Account ID</em>.</td></tr><tr><td valign="top">Field Name</td><td valign="top">The field you picked on the related object.</td></tr><tr><td valign="top">Filter</td><td valign="top">The operator, for example <em>Contain</em>.</td></tr><tr><td valign="top">Filter Type</td><td valign="top">Where the value comes from. Same options as a regular filter.</td></tr><tr><td valign="top">Value</td><td valign="top">The value to compare against.</td></tr></tbody></table>

Limits:

* You can add up to two cross filters per query.
* Filter logic isn't supported when the query has a cross filter.

## User Selection Fields

In User Selection modes, each field in the list has these columns. Compact shows only the search columns. Click Preview to view the Search and Select screen.

<table><thead><tr><th width="162.33334350585938" valign="top">Column</th><th valign="top">What it does</th></tr></thead><tbody><tr><td valign="top">Display + Order (Full only)</td><td valign="top">Shows the field as a column in the record list, in that order.</td></tr><tr><td valign="top">Search + Order</td><td valign="top">Shows the field as a filter on the Search and Select screen, in that order. In Full, if no field is set to Search, the screen has no filters panel.</td></tr><tr><td valign="top">Operator</td><td valign="top">The comparison the filter uses. See <a href="#operators-by-data-type">Operators by data type</a>.</td></tr><tr><td valign="top">Default Value</td><td valign="top">Pre-fills the filter value. For In and Not In, click the list icon to pick values. For Date &#x26; Time fields, use the date picker.</td></tr></tbody></table>

<figure><img src="https://2472585788-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFqFFf4143HS0_Wagnz%2Fuploads%2FwBm4vQIbeUz7osv42ftz%2FUser%20Selection%20Fields.gif?alt=media&amp;token=effdd6eb-bd85-4959-9e98-e36827a013df" alt=""><figcaption><p>Preview User Selection Screen</p></figcaption></figure>

### Operators by Data Type

The operators available for a search field depend on its data type.

<table><thead><tr><th width="200.11114501953125" valign="top">Data type</th><th valign="top">Operators</th></tr></thead><tbody><tr><td valign="top">String</td><td valign="top">Contain, Does Not Contain, Starts With, Ends With, Equal, Not Equal, In, Not In, Like</td></tr><tr><td valign="top">Picklist, Id</td><td valign="top">Equal, Not Equal, In, Not In</td></tr><tr><td valign="top">Currency, Date &#x26; Time</td><td valign="top">Equal, Not Equal, Greater Than, Greater Than Equal, Less Than, Less Than Equal, In, Not In, Between</td></tr></tbody></table>

In and Not In give the user a [list view](https://docs.valorx.com/valorx-fusion/runtime/runtime-ux/search-and-select.md#filters-list-view-and-operators) on the Search and Select screen for picking values.

### Required Fields

The Query Task won't save without these. A Missing Configuration message appears instead.

<table><thead><tr><th width="223.11111450195312" valign="top">Mode</th><th width="213.6666259765625" valign="top">Requirement</th><th valign="top">Message</th></tr></thead><tbody><tr><td valign="top">User Selection (Full)</td><td valign="top">At least one Display field</td><td valign="top">Please select at least one Display Field</td></tr><tr><td valign="top">User Selection (Compact)</td><td valign="top">At least one Search field</td><td valign="top">Please select at least one Search Field</td></tr></tbody></table>

<figure><img src="https://2472585788-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFqFFf4143HS0_Wagnz%2Fuploads%2FbB4dAr8DXAeE7W3jDwI4%2FRequired%20Fields.gif?alt=media&amp;token=d3b52bac-acee-4e5f-82ba-1392196b1047" alt=""><figcaption><p>Required Fields</p></figcaption></figure>
