Query builder operations

The query_builder operations can be used with any Object Type for the script. It returns a query that you can use as the query argument in helper.findIncidents(query).

Type query_builder. to access its operations.

The query_builder allows you to build queries. When building a query, be aware of the following:

  • The query_builder object has numerous match functions, including hasValue, hasNoValue, equals, notEquals, contains, notContains, isLessThan, isLessThanOrEquals, isGreaterThan, and isGreaterThanOrEquals. Each of these takes a field name as the first argument, as defined by the fields object.
  • The query_builder object has two sort functions, sortByAscending and sortByDescending. Each sort function also takes a field name as the first argument, as defined by the fields object. Sorts are applied in the order in which the sort functions are invoked.
  • The query_builder object has two control functions:
    • build(): Generates a query object that reflects the match and sort function calls that have been made on query_builder, and can be used with helper.findIncidents.
    • reset(): Clears all matches and sorts so that a new query can be constructed.
  • When creating a query, the return value from all of the match condition and sort specification functions is the query_builder object itself so that calls can be chained together; for example:
    query = query_builder.contains(fields.incident.name, 'foo').sortByAscending(fields.incident.id).build()
    This is equivalent to:
    query_builder.contains(fields.incident.name, "foo")
    query_builder.sortByAscending(fields.incident.id)
    query = query_builder.build()