General X++ Development
How do I convert an X++ select statement into a Query object?
How do I convert an X++ select statement into a Query object?
1 answer
Write an answerRebuild the same query structure with Query, QueryBuildDataSource, ranges, and links.
Query query = new Query();
QueryBuildDataSource custDs;
QueryBuildDataSource salesDs;
custDs = query.addDataSource(tableNum(CustTable));
salesDs = custDs.addDataSource(tableNum(SalesTable));
salesDs.relations(false);
salesDs.joinMode(JoinMode::InnerJoin);
salesDs.addLink(
fieldNum(CustTable, AccountNum),
fieldNum(SalesTable, CustAccount));The important part is not the syntax change. It is making sure the Query object has the same datasources, joins, ranges, and ordering as the original select.
Know the solution?
Sign in to contribute an answer and build your community reputation.
Sign in to answer