---
title: "Query functions"
site: admin
version: 1.11
versions: "all"
url: https://docs-new.servicely.ai/admin/1.11/automation/query-functions/
type: reference
application: platform
last_updated: 2026-10-18
commit: f37120b6b82b
---


A query function supplies a value at the moment a filter or default is used, such as the signed-in user or the dates of this year. This page lists the fields of both kinds of query function, for administrators with the `administrator` role.

| Kind | Used on | Menu |
| --- | --- | --- |
| Relationship query function | Reference and multiple reference fields, and catalog question defaults | **Application → Field → Relationship query functions** |
| Field query function | Other field types, mainly dates | **Application → Field → Field query functions** |

In a filter, select the lightning bolt icon next to a field to see the functions available for it.

## Relationship query functions

A relationship query function returns a record ID or a list of IDs. Use it in two places:

- in a list or report filter, for example "Assignee is Current user" to find your own incidents
- in **Default from function** on a catalog question, to default the answer, for example to the requester

<Image src="asset:screenshots/admin/automation-query-functions/image.png">The lightning bolt icon next to the Assignee filter, offering Current user.</Image>

| Field | Type | Behaviour | Purpose |
| --- | --- | --- | --- |
| Name | Text | Shown when you pick the function. | Names the function, for example "Current user location". |
| Function name | Text | Used when the function runs. | The internal name, for example `currentUserLocation`. |
| Number of expected arguments | Number | | How many arguments the function takes, usually 0. |
| Supported entities | List of tables | The function is offered only for fields and questions that reference these tables. | Limits where the function appears, for example Location. |
| Returns list? | Yes or no | | Turn on if the script returns a list. |
| Active | Yes or no | | Only active functions are offered. |
| Script | Script | The value of the last expression is returned. | Produces the ID or IDs, for example `user.Location.value();`. |

Servicely ships a **Current user** function on the User table, whose script is `user.getID();`.

<Image src="asset:screenshots/admin/automation-query-functions/image-3.png">A catalog question defaulted from the Current user function.</Image>

## Field query functions

A field query function returns a value or a date range for list and report filters, for example "Created is YTD".

<Image src="asset:screenshots/admin/automation-query-functions/image-4.png">A filter on a date field using the YTD function.</Image>

| Field | Type | Behaviour | Purpose |
| --- | --- | --- | --- |
| Name | Text | Shown when you pick the function. | Names the function, for example "YTD". |
| Function name | Text | Used when the function runs. | The internal name, for example `yearToDate`. |
| Number of expected arguments | Number | | How many arguments the function takes, usually 0. |
| Supported field types | List | The function is offered only for these field types. | Limits where it appears, for example `date` and `date_time`. |
| Returns list? | Yes or no | | Turn on if the script returns a list. |
| Returns range? | Yes or no | | Turn on if the script returns a start and an end. |
| Active | Yes or no | | Only active functions are offered. |
| Script | Script | The value of the last expression is returned. A range is an array of start and end. | Produces the value. |

Servicely ships no field query functions. These two scripts are examples.

Year to date, with **Returns range?** on:

```javascript
let end = DateTime();
let start = DateTime().withMonthOfYear(1).withDayOfMonth(1).toStartOfDay();
[start, end];
```

Last year, with **Returns range?** on:

```javascript
let end = DateTime().minusYears(1).withMonthOfYear(12).withDayOfMonth(31).toEndOfDay();
let start = DateTime().minusYears(1).withMonthOfYear(1).withDayOfMonth(1).toStartOfDay();
[start, end];
```

## Related

- [Question fields](page:catalog/questions)
- [Reference qualifiers](page:data-model/reference-qualifiers)
- [DateTime](page:api/scripting/datetime)
- [Where scripts run](page:automation/scripting-overview)
