Docs
On this page
reference1 min readApplication: Platform

Query functions

Fields of relationship and field query functions, which supply values such as the current user or year to date in filters and question defaults.

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
The lightning bolt icon next to the Assignee filter, offering Current user.
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();.

A catalog question defaulted from the Current user function.

Field query functions

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

A filter on a date field using the YTD function.
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:

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

Last year, with Returns range? on:

let end = DateTime().minusYears(1).withMonthOfYear(12).withDayOfMonth(31).toEndOfDay();
let start = DateTime().minusYears(1).withMonthOfYear(1).withDayOfMonth(1).toStartOfDay();
[start, end];
Last updated 18 October 2026commit f37120b6b82bChris Jones
Back to top