Servicely Configuration
Query Functions
8 min
query functions are used to dynamically provide a value or list of values based on the current user’s session there are two different versions of this, depending on what you want to achieve there are relationship query functions, used for reference and multiple reference fields, and field query functions, used for other field types (primarily datetime fields) relationship query functions the function, once configured and activated, will be available for the purpose of either of the below use the lightning bolt icon to show the list of available relationship query functions for the selected field, e g assignee adding to a query/filter on a table for a list or a report example below is using a relationship query function named “current user” to run a query to find incidents assigned to myself defaulting a catalog item question’s answer example below is using a relationship query function named “current user” to default a question’s answer to myself creating a relationship query function name type description example number of expected arguments integer 0 name string name of this function as shown when selecting it current user location function name string function name used when this is executed currentuserlocation supported entities list the function will be available to reference fields/catalog questions to the tables listed here for example if location table is a supported entity, then\ when you are setting up a filter for a table using a reference field that references location table, you will be able to select the relationship query functionorwhen you are configuring a catalog question that references location table, you will be able to select the relationship query function record on the “default from function” field location returns list? boolean set to yes if your configuration returns a list no active boolean set to yes to make it available yes script script should provide either list or an item last part of the code will be returned back for the query field query functions the function, once configured and activated, will be available for the purpose of adding to a query/filter on a table for a list or a report example below is using a field query function named “ytd” to run a query to find incidents for this year to date use the lightning bolt icon to show the list of available field query functions for the selected field, e g ytd creating a field query function name type description example number of expected arguments integer 0 name string name of this function as shown when selecting it ytd function name string function name used when this is executed yeartodate supported field types list the field types that will have this an option date date time returns list? boolean set to yes if your configuration returns a list no returns range? boolean set to yes if your configuration returns a range yes active boolean set to yes to make it available yes script script should provide either list or an item last part of the code will be returned back for the query other examples last year name type description example number of expected arguments integer 0 name string name of this function as shown when selecting it last year function name string function name used when this is executed lastyear supported field types list the field types that will have this an option date date time returns list? boolean set to yes if your configuration returns a list no returns range? boolean set to yes if your configuration returns a range yes active boolean set to yes to make it available yes script script should provide either list or an item last part of the code will be returned back for the query