Query string

Contents

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 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 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.
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.
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 or 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:
- DAYS
- WEEKS
- MONTHS
- YEARS
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:
- SUNDAY
- MONDAY
- TUESDAY
- WEDNESDAY
- THURSDAY
- FRIDAY
- SATURDAY
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:
- SUNDAY
- MONDAY
- TUESDAY
- WEDNESDAY
- THURSDAY
- FRIDAY
- SATURDAY
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:
- SUNDAY
- MONDAY
- TUESDAY
- WEDNESDAY
- THURSDAY
- FRIDAY
- SATURDAY
THIS_MONTH(number or text) - All days of this month
  created_datetime = THIS_MONTH()
- 23rd day of this month
  created_datetime = THIS_MONTH(23)
- Last day of this month
  created_datetime = THIS_MONTH(LAST)
Converts to the month of when the API was initiated.
The following can be specified:
- Numbers from 1-31 : the day of the month. If the number does not exist, it will convert to the first day of the next month.
- LAST : the last day of the month.
LAST_MONTH(number or text) - All days of the previous month
  created_datetime = LAST_MONTH()
- 23rd day of the previous month
  created_datetime = LAST_MONTH(23)
- Last day of the previous month
  created_datetime = LAST_MONTH(LAST)
Converts to the previous month of when the API was initiated.
The following can be specified:
- Numbers from 1-31 : the day of the previous month. If the number does not exist, it will convert to the first day of the month to follow.
- LAST : the last day of the previous month.
NEXT_MONTH(number or text) - All days of the next month
  Date = NEXT_MONTH()
- 23rd day of the next month
  Date = NEXT_MONTH(23)
- Last day of the next month
  Date = NEXT_MONTH(LAST)
Converts to the next month of when the API was initiated.
The following can be specified:
- Numbers from 1-31 : the day of the previous month. If the number does not exist, it will convert to the first day of the month to follow.
- LAST : the last day of the previous month.
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  
Number = != > < >= <= 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 = != > < >= <= TODAY()
YESTERDAY()
TOMORROW()
FROM_TODAY()
THIS_WEEK()
LAST_WEEK()
NEXT_WEEK()
THIS_MONTH()
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.
  • 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 record output is sorted based on the value of the field line after the option. “asc” will sort the records in ascending order, and “desc” will sort the records in descending order.
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.

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
1
Text like "sample" and Text_area like "sample" order by Created_datetime desc

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”
1
Drop_down in ("value1", "value2") and (Multi_choice in ("value3") or Radio_button in ("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
1
Time > 10:00 and Time < 19:00 and Created_datatime = TODAY() order by $id asc limit 10

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
1
User_selection in (LOGINUSER()) and Department_selection not in (PRIMARY_ORGANIZATION())

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”
1
Company_DB.company_name in ("kintone") and Company_DB.location like "San Francisco"