Nikos Kou
Nikos Kou

Reputation: 175

AOT Query relation OR case

For example I have the following x++ query.

Select EcoResproduct
   join tableX
       where EcoResproduct.RecId == tableX.Product
          || EcoResproduct.RecId == tableX.DistinctProductVariant;

Is that possible to do the same thing through AOT query without using a union query or adding two times the same datasource and without using QueryBuildDataSource object and X++ at all .

Thanks in advance

PS: I made my question more clear.

Upvotes: 0

Views: 1659

Answers (1)

10p
10p

Reputation: 6686

Initial incorrect answer:

Is that possible to do the same thing through an AOT query without using a union query or adding two times the same datasource

No.

Correct answer, thanks to the commenters:

Query q = new Query();
QueryBuildDataSource qbds1 = q.addDataSource(tableNum(EcoResproduct));
QueryBuildDataSource qbds2 = qbds1.addDataSource(tableNum(TableX));

qbds2.addrange(fieldNum(TableX, RecId)).value(strFmt('((%2.Product == %1.RecId) || (%2.DistinctProductVariant == %1.RecId))', qbds1.name(), qbds2.name()));

info(qbds1.toString());

Upvotes: 3

Related Questions