The Q object is an optional object of JSON Object type that can be passed as an @QueryParameter into many API calls. The purpose of this object is to format the API response. An example of such object is shown below:
All fields of the object are optional and are described below:
projection = JSON array of column names to be returned by request. In the example above, only the [WORK_ORDER_ID] and [STATUS] columns would be returned. If this field is omitted, then the request would return ALL available columns.
Note: This can be viewed as vertical filtering.
- sort = JSON Object, where keys are column names and values are the direction of the sort (DESC or ASC). This field specifies that the output should be sorted.
- filter = JSON array that contains three element JSON arrays and strings "AND" or "OR".
The inner JSON arrays represent the condition to filter by:
- The first element is the operand, usually a column name.
- The second element is the operator, such as "=", "BETWEEN", "IN."
- The third element is the operand to compare with, usually some value.
The "AND" or "OR" strings tell how conditions should be related in the WHERE clause.
Note: The filter is written using RPN (Reverse Polish Notation), where the operators are "AND", "OR" and the operands are the three-element JSON condition arrays. This can viewed as horizontal filtering.
- page = represents the pagination of the output.
- size = number of records per page, first record has index 1
- number = page number, first page has index 1
In the following example, all work orders are requested and use a Q object to limit the response to return only open work orders (status = 4). The response contains only two columns, sorted by work order start date, and returns the second page where there are 20 rows per page:
<baseUrl>/workOrder?q={"filter":[["STATUS","=",4]],"projection":["WORK_ORDER_ID","STATUS"],"sort":{"START_DATE":"DESC"},"page":{"size":20,"number":2}}