hi all ,
i have written one job , where i am joinning SalesTable and SalesLine
Please have a look.
static void QueryExample(Args _args)
{
Query query;
QueryRun queryRun;
QueryBuildDatasource datasource;
CustAccount custAccount;
SalesId salesId = "000761";
SalesTable salesTable;
SalesLine salesLine;
InventDim inventDim;
;
query = new Query();
// Add SalesTable main datasource
datasource = query.addDataSource(tableNum(SalesTable));
//Add range
datasource.addRange(fieldNum(salesTable,SalesId)).value(salesId);
// Add child datasource "SalesLine" to previously created DS
datasource = datasource.addDataSource(tableNum(SalesLine));
// Set the join mode
datasource.joinMode(JoinMode::InnerJoin);
// Indicate you don't want to use relations automatically
datasource.relations(false);
// Add link between parent field and child field
datasource.addLink(fieldNum(SalesTable, SalesId),
fieldNum(SalesLine, SalesId));
queryRun = new QueryRun(query);
while (queryRun.next())
{
salesLine = queryRun.get(tableNum(SalesLine));
salesTable = queryRun.get(tableNum(salesTable));
//inventDim = queryRun.get(tableNum(InventDim));
info("Sales Id from sales Table:"+salesTable.SalesId);
info("Sales Id from Sales Line :"+salesLine.SalesId);
info("Item Id :"+salesLine.ItemId);
info("UnitPrice :"+int2str(salesLine.CostPrice));
info("Quantity :"+int2str(salesLine.SalesQty));
info("Total Cost :"+int2str(salesLine.LineAmount));
//info("Location Id :"+inventDim.inventDimId);
}
}
This code is working fine.
Now i want to join one more Table that InventDim to SalesLine , so for that i have added some codes but its not working . Please have a look to the code which i have further added :-
datasource = datasource.addDataSource(tableNum(InventDim));
datasource.addLink(fieldNum(SalesLine,InventDimId),fieldNum(InventDim, InventDimId));
Please tell me what is need to do here .
Thanks
*This post is locked for comments