Добрый день!
Делаю Query:
X++:
static void _201_HTC_Query_fromCustJour(Args _args)
{
Query query;
QueryRun qr;
QueryBuildDataSource qbds, qbdsinvent;
QueryBuildRange qbr;
CustInvoiceJour custInvoiceJour;
CustInvoiceTrans custInvoiceTrans;
CustTable custTable;
InventBatchid inventBatchId = "141110-PO014116";
;
query = new Query();
qbds = query.addDataSource(tableNum(CustInvoiceJour));
qbds.addSortField(fieldNum(CustInvoiceJour, SalesId));
qbds = query.dataSourceTable(tableNum(CustInvoiceJour)).addDataSource(tableNum(CustTable));
qbds.relations(true);
qbds.fetchMode(QueryFetchMode::One2One);
qbds = query.dataSourceTable(tableNum(CustInvoiceJour)).addDataSource(tableNum(CustInvoiceTrans));
qbds.addRange(fieldNum(CustInvoiceTrans,ItemId)).value("P35080");
qbds.relations(true);
qbds.fetchMode(QueryFetchMode::One2One);
qbds = query.dataSourceTable(tableNum(CustInvoiceTrans)).addDataSource(tableNum(InventTrans));
qbds.addRange(fieldNum(InventTrans,InventTransId)).value("001720288");
qbds.relations(true);
qbds.fetchMode(QueryFetchMode::One2One;
qr = new QueryRun(query);
info(query.dataSourceTable(tableNum(CustInvoiceJour)).toString());
while (qr.next())
{
custInvoiceJour = qr.get(tablenum(CustInvoiceJour));
custInvoiceTrans = qr.get(tablenum(CustInvoiceTrans));
custTable = qr.get(tablenum(CustTable));
info(strfmt("%1 | %2 | %3 | %4", custInvoiceJour.SalesId, custTable.Name, custInvoiceTrans.ItemId, custInvoiceTrans.Qty));
}
}
На выходе получаю правильную агрегированную запись но дважды. Вопрос как сделать чтобы один раз а не два?