19.06.2017, 15:54 | #1 |
Участник
|
Запрос ИЛИ в query
Всем доброго дня. AX 4. Прошу помощи вот в каком вопросе. Создаю query как написано ниже. Если запускать так то все работает. Но если раскоментировать присоединение InventTable, то система начинает игнорировать наложение range по InventLocationType.
Может кто-нибудь сталкивался с подобным? Посоветуйте как это победить? X++: query = new Query(); qbdsItt = query.addDataSource(tablenum(InventTransferTable), "Transfer"); qbdsItt.orderMode(OrderMode::GroupBy); qbdsItt.addRange(fieldnum(InventTransferTable, ReceiveDate)).value(strfmt('%1..%2', fromDate, toDate)); qbdsItt.addRange(fieldnum(InventTransferTable, TransferStatus)).value(QueryValue(InventTransferStatus::Received)); qbdsItt.addRange(fieldnum(InventTransferTable, InventLocationIdFrom)).value(inventLocationIdFrom); qbdsItl = qbdsItt.addDataSource(tablenum(InventTransferLine)); qbdsItl.addLink(fieldnum(InventTransferLine , TransferId), fieldnum(InventTransferTable, TransferId)); qbdsItl.joinMode(JoinMode::InnerJoin); qbdsItl.orderMode(OrderMode::GROUPBY); qbdsItl.fetchMode(QueryFetchMode::One2One); /* qbdsIt = qbdsItl.addDataSource(tableNum(InventTable)); qbdsIt.relations(true); qbdsIt.joinMode(joinMode::InnerJoin); */ if (inventLocationType != InventLocationType::Standard) { qbdsInventLocationFrom = qbdsItt.addDataSource(tablenum(InventLocation)); qbdsInventLocationFrom.addLink(fieldNum(InventTransferTable, InventLocationIdFrom), fieldNum(InventLocation, InventLocationId)); qbdsInventLocationFrom.joinMode(JoinMode::ExistsJoin); qbdsInventLocationFrom.fetchMode(QueryFetchMode::One2One); qbdsInventLocationTo = qbdsItt.addDataSource(tableNum(InventLocation)); qbdsInventLocationTo.addLink(fieldNum(InventTransferTable, InventLocationIdTo), fieldNum(InventLocation, InventLocationId)); qbdsInventLocationTo.joinMode(JoinMode::ExistsJoin); qbdsInventLocationTo.fetchMode(QueryFetchMode::One2One); qbrDataAreaId = qbdsInventLocationTo.addRange(fieldNum(InventLocation, DataAreaId)); qbrDataAreaId.value(strFmt('((%1.%3 == %4) || (%2.%3 == %4))', qbdsInventLocationFrom.name(), qbdsInventLocationTo.name(), fieldStr(InventLocation, InventLocationType), any2int(inventLocationType))); } queryRun = new QueryRun(query); rowCount = SysQuery::countLoops(queryRun); |
|