I'm trying to modify an existing query within a class through this custom method:
private void SetQuery() { Query q; QueryBuildDataSource q0; QueryBuildDataSource q1; QueryBuildDataSource q2; QueryBuildDataSource q3; q = chooseLines.query(); q0 = q.dataSourceTable(tableNum(custPackingSlipTrans)); q1 = q0.addDataSource(tableNum(InventTransOrigin)); q1.addLink(fieldNum(custPackingSlipTrans,InventTransId),fieldNum(InventTransOrigin,InventTransId)); q2 = q1.addDataSource(tableNum(InventTrans)); q2.addLink(fieldNum(InventTransOrigin,RecId),fieldNum(InventTrans,InventTransOrigin)); q2.addLink(fieldNum(custPackingSlipTrans,PackingSlipId),fieldNum(InventTrans,PackingSlipId)); q2.addRange(fieldNum(InventTrans, StatusIssue)).value(strFmt('((statusreceipt == 2) || (statusissue == 2))')); chooseLines.query(q); }
However, the query remains as original, my new datasources are not added to it. What am i doing wrong?
The Original query.tostring() is like this:
# Without changes: SELECT WITH FORCE_PLACEHOLDERS FIRSTFAST * FROM SalesTable(SalesTable) ORDER BY SalesLine.SalesId ASC, SalesLine.LineNum ASC WHERE ((SalesStatus>=1 AND SalesStatus<=2)) JOIN FIRSTFAST * FROM SalesLine(SalesLine) ON SalesTable.SalesId = SalesLine.SalesId AND ((Blocked = 0)) OUTER JOIN * FROM CustPackingSlipTrans(CustPackingSlipTrans) ON SalesLine.InventTransId = CustPackingSlipTrans.InventTransId AND ((FullyMatched = 0)) OUTER JOIN * FROM InventDim(InventDim) ON CustPackingSlipTrans.InventDimId = InventDim.inventDimId EXISTS JOIN * FROM CustPackingSlipJour(CustPackingSlipJour_1) WHERE CustPackingSlipTrans.SalesId = CustPackingSlipJour.SalesId AND CustPackingSlipTrans.PackingSlipId = CustPackingSlipJour.PackingSlipId AND CustPackingSlipTrans.DeliveryDate = CustPackingSlipJour.DeliveryDate AND ((DocumentDate = {ts '2018-01-02 00:00:00.000'}))
Actually SalesTable and SalesLine are the parent data sources, but i need my relation at CustPackingSlip level, which is the second child in the query
*This post is locked for comments
Maybe you're calling toString() on a wrong query.
Or maybe the query is all right and the only problem is that toString() doesn't always give exact information. Try query.xml() instead of query.toString().
Hi Ghetz,
Did you also updated the CIL (full or incremental)? If not, you might have tested the code on the old version of the software which did not have the adjustments.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156