This function is unique because it helps you create a search condition (query) for retrieving records by providing specific conditions. The Q function enables you to write concise segments of complex expressions that would otherwise need to be written using the text join function.
Take any number of parameters and enclose the value of each parameter in double quotation marks, separated by commas. If you pass an array as a parameter, apply the same format to each element in the array. Each element should be enclosed in double quotation marks and separated by commas.
In addition, the inner part enclosed by double quotation marks is escaped for Kintone’s query. In “[Retrieve Records by Providing Conditions in Query] (../../actions/record/get_records_by_escaped_query/)”, the result of ${expression} is escaped, but in the case of ${q(…)} the escape is not performed twice, as the Q function itself performs it.
In the example notation below, “(result)⇒XXX” represents the result of executing that expression. Do not enter “(result)⇒XXX” in the expression.
= q ("Tokyo", "Osaka", "Nagoya")
(Result)⇒"Tokyo", "Osaka", "Nagoya".
= q(["Tokyo", "Osaka", "Nagoya"])
(Result)⇒"Tokyo", "Osaka", "Nagoya".
In the example below, the “Departure” field contains the value Tokyo and the “Arrival” field contains the value Osaka.
= q(Departure, Arrival)
(Result)⇒"Tokyo", "Osaka"
In the example below, assume that the Prefecture is a multi-choice field with Tokyo and Osaka selected.
= q(Prefecture )
(Result)⇒"Tokyo", "Osaka"
You can also combine arrays and non-arrays. This allows you to specify the field’s selected and fixed values.
= q(Prefecture, "Hokkaido")
(Result)⇒"Tokyo", "Osaka", "Hokkaido"
The function can be used in the User, Department, and Group selection fields. In this case, the value is the user’s login name.
In the following example, assume that the User selection field has three selected: “Jane”, “John”, and “Ken”.
= q(User selection)
(Result)⇒"Jane", "John", "Ken"
The following is an example query to retrieve records by selecting Prefecture or Hokkaido in the Prefecture.
Prefecture in (${q(Prefecture, "Hokkaido")})