How to add a "sorts" object to an existing query object
Hi dear community.
Note: I do have a workaround for the situation below, and that is to Sort separately the result of the QDTE service, but I was wondering why this method of attaching the sorts object does not work in the way I designed it.
Problem:
I have a relatively simple scenario where I encountered an issue. In ThingWorx 8.5.4, I have an advanced grid, bound to a custom service that has a query object as a QUERY-type parameter.
EnableGridSearch is enabled, and the widget's QueryFilter is bound to the service's query input parameter.
In my custom service I want to sort the results of a QueryDataTableEntries based on a "timestamp" field (DATETIME) to make sure the grid always displays the most recent field as the first item in the grid.
Because of the fact that the grid will always supply a "filters" section in my query object, I would like to attach my "sorts" key to what comes back from the grid.
I can attach the "sorts" key to the object (by setting it straight as an array - query.sorts = [{"fieldName": "timestamp","isAscending": false}]; Declaring it as [] or new Array() does not work)
However, the issue is that the sorts does not have an effect on the QDTE service if it's attached to the initial query object.
For reference, the final constructed object that gets passed to QDTE is the following:
{
"filters": {
"filters": [
{
"fieldName": "ID",
"type": "LIKE",
"value": "%pull%"
},
{
"fieldName": "sourceType",
"type": "LIKE",
"value": "%pull%"
},
{
"fieldName": "location",
"type": "LIKE",
"value": "%pull%"
},
{
"fieldName": "timestamp",
"type": "LIKE",
"value": "%pull%"
},
{
"fieldName": "Source",
"type": "LIKE",
"value": "%pull%"
},
{
"fieldName": "source",
"type": "LIKE",
"value": "%pull%"
},
{
"fieldName": "User",
"type": "LIKE",
"value": "%pull%"
},
{
"fieldName": "key",
"type": "LIKE",
"value": "%pull%"
},
{
"fieldName": "ServiceName",
"type": "LIKE",
"value": "%pull%"
},
{
"fieldName": "Content",
"type": "LIKE",
"value": "%pull%"
},
{
"fieldName": "tags",
"type": "LIKE",
"value": "%pull%"
}
],
"type": "OR"
},
"sorts": [
{
"isAscending": false,
"fieldName": "timestamp"
}
]
}
I have the feeling that I'm maybe not constructing the array required by the sorts in a proper way?

