Hello,
I have this code:
pickingListQuery = new Query();
qbdsPickingList = pickingListQuery.addDataSource(tableNum(ProdJournalBOM));
pickingListQuery.dataSourceTable(tableNum(ProdJournalBOM)).addRange(fieldNum(ProdJournalBOM,JournalId)).value(pickingListJour);
qbdsPickingList.sortClear();
qbdsPickingList.addSelectionField(fieldNum(ProdJournalBOM,BOMProposal), SelectionField::Sum);
qbdsPickingList.addSortField(fieldNum(ProdJournalBOM, LineNum));
qbdsPickingList.addGroupByField(fieldNum(ProdJournalBOM, ItemId));
qbdsPickingList.addGroupByField(fieldNum(ProdJournalBOM, BOMUnitId));
qbdsInventDim = qbdsPickingList.addDataSource(tableNum(InventDim));
qbdsInventDim.sortClear();
qbdsInventDim.relations(true);
qbdsInventDim.orderMode(OrderMode::GroupBy);
qbdsInventDim.addSortField(fieldNum(InventDim, InventLocationId));
pickingListQueryRun = new QueryRun(pickingListQuery);
while(pickingListQueryRun.next())
{
It return this query: SELECT FIRSTFAST SUM(BOMProposal) FROM ProdJournalBOM GROUP BY ProdJournalBOM.ItemId, ProdJournalBOM.BOMUnitId, InventDim.InventLocationId ORDER BY ProdJournalBOM.LineNum ASC WHERE ((JournalId = N'PRJ254364')) JOIN FIRSTFAST * FROM InventDim WHERE ProdJournalBOM.InventDimId = InventDim.inventDimId;
And the Order By clause seems to not working. And records are sorted by ItemId.
Any suggestions?