# Named Query Technical Reference

Canonical page: https://www.adaptabletools.com/docs/technical-reference-named-query

## Named Query State

| Property | Type | Description |
| --- | --- | --- |
| [NamedQueries](https://www.adaptabletools.com/docs/reference/namedquerystate.md#namedqueries) | [`NamedQuery`](https://www.adaptabletools.com/docs/reference/namedquery.md)`[]` | Named Queries other expressions can reference with `QUERY('Name')`. |

### Named Query 

| Property | Type | Description |
| --- | --- | --- |
| [Description](https://www.adaptabletools.com/docs/reference/namedquery.md#description) | `string` | Optional description of what the query computes;<br/>shown in the Expression Editor lookups and Named Query views. |
| [Expression](https://www.adaptabletools.com/docs/reference/namedquery.md#expression) | `string` | AdapTableQL Expression evaluated per row (scalar; aggregations are not allowed in Named Queries) |
| [Name](https://www.adaptabletools.com/docs/reference/namedquery.md#name) | `string` | Name of the Query, used to reference it in AdaptableQL Expressions |
| [ReturnType](https://www.adaptabletools.com/docs/reference/namedquery.md#returntype) | [`NamedQueryReturnType`](https://www.adaptabletools.com/docs/reference/namedqueryreturntype.md) | Return type of the expression. When omitted, the query is treated as `'boolean'` and can be used as a Grid Filter or Alert rule. |
| [IsReadOnly](https://www.adaptabletools.com/docs/reference/namedquery.md#isreadonly) | `boolean` | Sets Entity to ReadOnly (overwriting a Strategy Entitlement of &#39;Full&#39;) |

`ReturnType` is a [`NamedQueryReturnType`](https://www.adaptabletools.com/docs/reference/namedqueryreturntype.md):

[See API: namedqueryreturntype](https://www.adaptabletools.com/docs/reference/namedqueryreturntype.md)

- A Named Query's `Expression` can resolve to *any* value (Boolean, number, text or date)
- Only Named Queries which resolve to a Boolean can be loaded as a [Grid Filter](https://www.adaptabletools.com/docs/handbook-grid-filter/index.md)
- Scalar Named Queries can be referenced (via `QUERY`) anywhere a value is expected - e.g. in [Calculated Columns](https://www.adaptabletools.com/docs/handbook-calculated-column/index.md)

---

## Named Query API

| Method | Returns | Description |
| --- | --- | --- |
| [addNamedQueries(namedQueries)](https://www.adaptabletools.com/docs/reference/namedqueryapi.md#addnamedqueries) | `void` | Adds several Named Queries to Adaptable State. |
| [addNamedQuery(namedQueries)](https://www.adaptabletools.com/docs/reference/namedqueryapi.md#addnamedquery) | `void` | Adds a new Named Query to Adaptable State |
| [getNamedQueries()](https://www.adaptabletools.com/docs/reference/namedqueryapi.md#getnamedqueries) | [`NamedQuery`](https://www.adaptabletools.com/docs/reference/namedquery.md)`[]` | Gets all Named Queries in Adaptable State |
| [getNamedQueryByName(namedQueryName)](https://www.adaptabletools.com/docs/reference/namedqueryapi.md#getnamedquerybyname) | [`NamedQuery`](https://www.adaptabletools.com/docs/reference/namedquery.md)` \| undefined` | Retrieves Named Query with given name from State |
| [getNamedQueryState()](https://www.adaptabletools.com/docs/reference/namedqueryapi.md#getnamedquerystate) | [`NamedQueryState`](https://www.adaptabletools.com/docs/reference/namedquerystate.md) | Retrieves Query section from Adaptable State |
| [isValidNamedQuery(namedQuery)](https://www.adaptabletools.com/docs/reference/namedqueryapi.md#isvalidnamedquery) | `NamedQueryValidationResult` | Whether this Named Query can be saved. The name is required and must not already be used. |
| [openNamedQuerySettingsPanel()](https://www.adaptabletools.com/docs/reference/namedqueryapi.md#opennamedquerysettingspanel) | `void` | Opens Settings Panel with Query section selected and visible |
| [runNamedQuery(namedQuery)](https://www.adaptabletools.com/docs/reference/namedqueryapi.md#runnamedquery) | `void` | Runs the given Named Query |
| [runQueryByName(queryName)](https://www.adaptabletools.com/docs/reference/namedqueryapi.md#runquerybyname) | `void` | Runs Named Query which has given name |
