Join table A - B and A - C with Axapta query

Hi All,

I tried:

 


Query query = new Query();
QueryBuildDataSource qbds,qbds1,qbds2;
querybuildrange r;
;
qbds = query.addDataSource(tableNum(smaserviceordertable));
qbds1 = qbds.addDataSource(tableNum(b_repairjournal));
qbds1.relations(false);
qbds1.addLink(fieldNum(b_repairjournal,serviceorderid),fieldNum(smaserviceordertable,serviceorderid));
qbds2 = qbds1.addDataSource(tableNum(inventtable));
qbds2.relations(false);
qbds2.addLink(fieldNum(smaserviceordertable,itemid),fieldNum(inventtable,itemid));

info(qbds.toString());

 

Also I tried:

qbds2.addRange(fieldNum(inventtable,itemid)).value("( smaserviceordertable.itemid == inventtable.itemid )");

instead of :

qbds2.addLink(fieldNum(smaserviceordertable,itemid),fieldNum(inventtable,itemid));

 

It didn't worked too.

 

That doesn't works too:

 

Query query = new Query();
QueryBuildDataSource qbds,qbds1,qbds2;
querybuildrange r;
;
qbds = query.addDataSource(tableNum(smaserviceordertable));
qbds1 = qbds.addDataSource(tableNum(b_repairjournal));
qbds1.relations(false);
qbds1.addLink(fieldNum(b_repairjournal,serviceorderid),fieldNum(smaserviceordertable,serviceorderid));
qbds2 = qbds.addDataSource(tableNum(inventtable));
qbds2.relations(false);
qbds2.addLink(fieldNum(smaserviceordertable,itemid),fieldNum(inventtable,itemid));

info(qbds.toString());

 

What should I do? I know I can do it with using select - SQL but I should use query in this case.

Related
Recommended