diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 899fe05cd..8d93fb993 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -347,6 +347,17 @@ module.exports = Self => { if (hasWhere) stmt.merge(conn.makeWhere(problems)); + if (filter.order) { + const index = filter.order.findIndex(o => o.includes('stateFk')); + if (index > -1) { + filter.order = [ + ...filter.order.slice(0, index), + 'refFk ' + filter.order[index].split(' ')[1], + ...filter.order.slice(index) + ]; + } + } + stmt.merge(conn.makeOrderBy(filter.order)); stmt.merge(conn.makeLimit(filter)); const ticketsIndex = stmts.push(stmt) - 1;