Query Examples for the Get Records API
Overview
This article introduces the basic query examples for the Get Records API.
Get Records API
Conditions can be set when retrieving the records by specifying the query string. The data can also be sorted, making it easier to organize.
Creating the Sample App
For better understanding, this article uses the following app to provide examples.
Adding the Help Desk Management App
Add the Help Desk Management App from the Kintone marketplace by following the tutorial on the Kintone Help Site:
Adding a sample app
Navigate to the Help Desk Management App and click the App settings icon (gear icon).
Add a Date field to the form for the Deadline. Then update the field name and field code for each field in the form to match the table below. Save the form when finished.
Field Type | Field Name | Field Code / Element ID |
---|---|---|
Text | Organization | Organization |
Radio button | Inquiry Type | Inquiry_type |
Date | Deadline | Deadline |
Date and time | Date and time (in the "Support History" table) | Support_date |
Creating the Sample Data
Create sample data for the query testing as follows. The fields not included in the chart below can be set to any sample data.
Organization | Name | Status | Deadline | Support_date |
---|---|---|---|---|
DEF Inc. | Sage H | Complete | Feb 01, 2025 | Jan 15, 2025 3:00 PM |
ABC Corporation | Jean C | In progress | Jan 01, 2025 | Feb 07, 2025 5:00 PM |
Sage H's record
Sample data in the All fields view
How to Write Query Strings
This section introduces how to write query strings and provides sample queries for using the Get Records API.
Format
A query is expressed in the following format.
|
|
For more detailed specifications of queries and the operators and functions that can be used for each field, refer to the following article:
Query string
A sample of retrieving records by specifying a query in JavaScript is introduced in the following section:
Using Variables in Queries
Next, the method and sample queries for each field will be introduced.
Text Field Value Specification (Single-line)
Exact match: When the value of the "Organization" fields is "ABC Corporation"
To specify text that exactly matches a specified value, use the =
operator as follows:
|
|
Partial match: When the value of the "Organization" field contains "Corporation"
To specify text that partially matches a specified value, use the like
operator as follows:
|
|
Drop-down Field Value Specification
To specify the value for a Drop-down field, use the in
or not in
operator as follows.
When using the in
or not in
operator, the value must be enclosed in ()
.
When the value of the "Status" field contains "Not handled yet" or "In progress"
|
|
When the value of the "Status" field does not contain "Complete"
|
|
In addition, the following fields can also be retrieved using the in
or not in
operators:
- Check box
- Radio button
- Multi-choice
Date Field Value Specification
When the value of the "Deadline" fields is "Feb 01, 2025"
|
|
When the value of the "Deadline" fields is from "Jan 01, 2025" to "Feb 01, 2025"
The following query retrieves records within a given date range. When specifying multiple conditions, use the and
operator to link the expressions together.
|
|
Field in a Table's Value Specification
The =
and !=
operators are generally used for the Date and Date and Time fields. However, they cannot be applied to tables.
Instead, use the in
or not in
operator.
When the value of the "Support_date" field is "Mar 27, 2025 3:00 PM"
|
|
Multiple Fields and Conditions Specification
Multiple conditions can be specified using the and
and or
operators.
Specify multiple conditions using "and"
- The value of Deadline field is earlier than
Today
. - The value of Status field does not include
Complete
.
|
|
The TODAY()
function is one of the functions that can be used in queries.
These functions allow for easy specification of conditions such as TODAY()
, LAST_WEEK()
or NEXT_WEEK()
without having to specify the date each time.
For more information on functions, refer to the following article:
Query Functions
Sort retrieved records using "order by"
Additionally, another condition can be added to the previous one.
- The value of Deadline field is earlier than
Today
. - The value of Status field does not include
Complete
. - The Deadline field value is retrieved in ascending order.
|
|
In this way, order by
option sorts the output records in ascending order.
Group Expressions
When specifying multiple conditions for multiple fields, group the expressions.
Expressions can be grouped by enclosing them in parentheses ()
.
Grouping allows for the specification of more detailed conditions.
Specify conditions for grouping expressions
The value of the Inquiry Type field is Partnership
or the value of the Deadline field is from 2025-01-01
to 2025-02-01
.
|
|
Using Variables in Queries
When writing a query in JavaScript, there may be cases where including variables within the query is necessary.
For example, to use a value obtained from a record in a query, it is necessary to assign the value to a variable.
Consider the case in which it is necessary to retrieve other records that share the same Deadline value when a record is opened. To implement this condition, follow this specific order of processing:
- Retrieve the value of the opened record.
- Assign the retrieved value to a variable and use it in the query string.
The code is as follows:
|
|
On line 6, the value of the Deadline field is assigned to the deadline
variable.
The deadline
variable can now be used as a condition for record retrieval. Combine the conditions to create a query string as shown in line 7.