Query string
Query Operators and Functions
Query Operators
OPERATOR | SAMPLE | RESPONDED RECORDS |
---|---|---|
= |
string_0 = "test" |
Records where the field line value before the operator and the string after the operator match. |
!= |
string_0 != "test" |
Records where the field line value before the operator and the string after the operator don't match. |
> |
number_0 > 10 |
Records where the field line value before the operator is greater than the value after the operator. |
< |
number_0 < 10 |
Records where the field line value before the operator is less than the value after the operator. |
>= |
number_0 >= 10 |
Records where the field line value before the operator is greater than or equal to the value after the operator. |
<= |
number_0 <= 10 |
Records where the field line value before the operator is less than or equal to the value after the operator. |
in |
dropdown_0 in ("A", "B") |
Records where the field line value before the operator matches any of the strings listed in the brackets after the operator. This expression can be used to find what choices have been selected for fields that have multiple selections, such as Drop-down fields and Radio button fields. The sample on the left responds records where the options "A" or "B" have been selected for the "dropdown_0" field. |
not in |
dropdown_0 not in ("A", "B") |
Records where the field line value before the operator don't matches any of the strings listed in the brackets after the operator. This expression can be used to find what choices have not been selected for fields that have multiple selections, such as Drop-down fields and Radio button fields. The sample on the left responds records where the options "A" or "B" haven't been selected for the "dropdown_0" field. |
like |
Single_line_text_0 like "test" |
Records where the string after the operator is included in the field line value before the operator. If an Attachment field is specified, records where the string after the operator is included in the file name or the contents of the file will be responded. Refer to the following article from the Kintone Help for information about the symbols that cannot be used: Points to note when entering search keywords |
not like |
Single_line_text_0 not like "test" |
Records where the string after the operator is not included in the field line value after the operator. Refer to the following article from the Kintone Help for information about the symbols that cannot be used: Points to note when entering search keywords |
or |
number_0 < 10 or number_0 > 20 |
Records where the expression on either side of the or is true.The sample on the left responds records where the value of "number_0" is less than 10, or greater than 20. |
and |
number_0 >= 10 and number_0 <= 20 |
Records where the expression on both sides of the and is true.The sample on the left responds records where the value of "number_0" is greater than or equal to 10, and less than or equal to 20. |
- Field codes are to be placed before the operator, not after it.
- Formulas can be grouped by using
()
brackets.
For example, (number_0 >= 10 and number_0 <= 20) or (number_1 >= 100 and number_1 <= 200)
Query Functions
FUNCTION | SAMPLE | DESCRIPTION |
---|---|---|
LOGINUSER() |
author in (LOGINUSER()) | Converts to the user initiating the API. |
PRIMARY_ORGANIZATION() |
department in (PRIMARY_ORGANIZATION()) | Converts to the Priority Department of the user initiating the API. |
NOW() |
created_datetime = NOW() | Converts to the date and time of when the API was initiated. |
TODAY() |
created_datetime = TODAY() | Converts to the date when the API was initiated. |
YESTERDAY() |
created_datetime = YESTERDAY() | Converts to the date 1 day before the API was initiated. |
TOMORROW() |
Date = TOMORROW() | Converts to the date 1 day after the API was initiated. |
FROM_TODAY(number, period) |
created_datetime < FROM_TODAY(5, "DAYS") | The below periods can be specified:
|
THIS_WEEK() |
created_datetime = THIS_WEEK(SUNDAY) | Converts to the specified day in this week. Weeks start from a Sunday. If nothing is specified, it converts to all days in this week, starting from Sunday. The following days of the week can be set:
|
LAST_WEEK() |
created_datetime = LAST_WEEK() | Converts to the specified day in the previous week. Weeks start from a Sunday. If nothing is specified, it converts to all days in the previous week, starting from Sunday. The following days of the week can be set:
|
NEXT_WEEK() |
created_datetime = NEXT_WEEK() | Converts to the specified day in the next week. Weeks start from a Sunday. If nothing is specified, it converts to all days in the next week, starting from Sunday. The following days of the week can be set:
|
THIS_MONTH(number or text) |
|
Converts to the month of when the API was initiated. The following can be specified:
|
LAST_MONTH(number or text) |
|
Converts to the previous month of when the API was initiated. The following can be specified:
|
NEXT_MONTH(number or text) |
|
Converts to the next month of when the API was initiated. The following can be specified:
|
THIS_YEAR() |
created_datetime = THIS_YEAR() | Converts to the year of when the API was initiated. |
LAST_YEAR() |
created_datetime = LAST_YEAR() | Converts to the year before the API was initiated. |
NEXT_YEAR() |
Date = NEXT_YEAR() | Converts to the year after the API was initiated. |
Available Operators and Functions for Each Field
FIELD | OPERATIONS | FUNCTIONS |
---|---|---|
Record Number | = != > < >= <= in not in |
|
$id | = != > < >= <= in not in |
|
Created by | in not in |
LOGINUSER() |
Created datetime | = != > < >= <= |
NOW() TODAY() YESTERDAY() TOMORROW() FROM_TODAY() THIS_WEEK() LAST_WEEK() NEXT_WEEK() LAST_MONTH() NEXT_MONTH() THIS_YEAR() LAST_YEAR() NEXT_YEAR() |
Updated by | in not in |
LOGINUSER() |
Updated datetime | = != > < >= <= |
NOW() TODAY() YESTERDAY() TOMORROW() FROM_TODAY() THIS_WEEK() LAST_WEEK() NEXT_WEEK() LAST_MONTH() NEXT_MONTH() THIS_YEAR() LAST_YEAR() NEXT_YEAR() |
Text | = != in not in like not like |
|
Link | = != in not in like not like |
|
Number | = != > < >= <= in not in |
|
Calculated | = != > < >= <= in not in |
|
Text area | like not like |
|
Rich text | like not like |
|
Check box | in not in |
|
Radio button | in not in |
|
Drop-down | in not in |
|
Multi-choice | in not in |
|
Attachment | like not like |
|
Date | = != > < >= <= |
NOW() TODAY() YESTERDAY() TOMORROW() FROM_TODAY() THIS_WEEK() LAST_WEEK() NEXT_WEEK() LAST_MONTH() NEXT_MONTH() THIS_YEAR() LAST_YEAR() NEXT_YEAR() |
Time | = != > < >= <= |
|
Date and time | = != > < >= <= |
NOW() TODAY() YESTERDAY() TOMORROW() FROM_TODAY() THIS_WEEK() LAST_WEEK() NEXT_WEEK() LAST_MONTH() NEXT_MONTH() THIS_YEAR() LAST_YEAR() NEXT_YEAR() |
User selection | in not in |
LOGINUSER() |
Department selection | in not in |
PRIMARY_ORGANIZATION() |
Group selection | in not in |
|
Status | = != in not in |
|
Lookup | Same as the field type it is looking up. | Same as the field type it is looking up. |
Related Records | Same as the field type of the datasource App field.= and != operators are unusable, and must be replaced with in and not in operators. |
Same as the field type of the datasource App field. |
Fields within Tables | Same as the field type of the field in the Table.= and != operators are unusable, and must be replaced with in and not in operators. |
Same as the field type of the field in the Table. |
Group | Not available | |
Category | Not available |
Specifying fields within related record fields
- Specify fields within the Related Records field with the following format:
relatedrecords.specifiedfield
where relatedrecords is the field line of the Related Records field, and specifiedfield is the field line of the specified field.
Query Options
The below options can be used in conjunction.
OPTION | SAMPLE | DESCRIPTION |
---|---|---|
order by |
order by Updated_Datetime asc | The order of the records is sorted based on the value of the field code after this option. asc sorts the records in ascending order, and desc sorts the records in descending order. To specify sort orders on multiple fields, separate them with commas.e.g. order by fieldcode1 desc, fieldcode2 asc |
limit |
limit 20 | The number of records outputted is determined by the value after this option. The initial number is 100 records, and the maximum is 500. |
offset |
offset 30 | This skips outputting the first number of records. The example on the left skips the first 30 records, and outputs from the 31st record. The maximum is 10000. |
Escape Characters
Query sensitive parameters such as "
(Double Quotations) and \
(Backslashes) must be properly escaped using a \
backslash when included in a query string for the following fields:
- Text
- Text area
- Rich text
- Check box
- Radio button
- Drop-down
- Multi-choice
- Status
Sample Queries Containing Escape Characters
In this example, a Check box field with the field code Checkbox
is queried. The value of the Check box is sample"1"
, which includes double quotations and therefore must be escaped properly.
|
|
Similarly, this Check Box field has a value of sample\2\
, which requires the backslash characters to be escaped.
|
|
When using the Kintone REST API, sensitive characters must be escaped within the request body JSON as well and require additional backslashes.
In the example below, for sending the value sample"1"
in a request body, note that JavaScript requires a backslash to escape, in addition to the escape required for Kintone query strings.
|
|
Similarly, sending the value sample\1\
also requires one escape character for JavaScript and one for Kintone's query string.
|
|
Sample Queries
Sample 1
- the field Text includes the string "sample"
- the field Text_area includes the string "sample"
- results are listed in descending order of the field Created_datetime
|
|
Sample 2
- the field Drop_down includes the values "value1" or "value2"
- the field Multi_choice includes the value "value3" or the field Radio_button includes the value "value4"
|
|
Sample 3
- the field Time is greater than the value "10:00"
- the field Time is less than the value "19:00"
- the field Created_datetime is equal to today's date
- results are listed in ascending order of the Record number field
- only up to the first 10 results are outputted
|
|
Sample 4
- The user running the API call is included in the field User_selection
- The priority department of the user running the API call is not included in the field Department_selection
|
|
Sample 5
- The field company_name within the field Company_DB (a Related Records field) has a value equal to "kintone"
- The field location within the field Company_DB (a Related Records field) includes the string "San Francisco"
|
|