Query execution using x++
In this article I will be going over how we can write a code based query to retrieve and filter data from the database without having to write a select statement. For this example, I am going to extract the customer and sales order information for a specific customer. Query query = new Query(); QueryBuildDataSource salesOrderQueryBuildDataSource = query.addDataSource(tableNum(SalesTable)); // add range for sales order with Id 1003 salesOrderQueryBuildDataSource.addRange(fieldNum(SalesTable, SalesId)).value(queryValue('1003')); // join the customer table to retrieve the customer details QueryBuildDataSource custTableQueryBuildDataSource = salesOrderQueryBuildDataSource.addDataSource(tableNum(CustTable)); // add join type custTableQueryBuildDataSource.joinMode(JoinMode::Exists); // add join link custTableQueryBuildDataSource.addLink(fieldNum(SalesTable, CustAccount), fieldNum(CustTable, AccountNum)); // initiate query execution QueryRun queryRun = new QueryRun(qu...