I need to dynamically specify any AOT query, then read back the columns and values.
I am pretty close. The only problem is that it lists ALL fields in each datasource instead of just the fields specified to return values in the query.
Any suggestions how I can get this to return query result fields only, instead of all columns in the datasource?
Thanks,
Brad
while (queryRun.next()) { //parse through each datasource for(i = 1; i <= workingQuery.dataSourceCount(); i++) { //get all fields in this data source qbfl = workingQuery.dataSourceNo(i).fields(); cnt = qbfl.fieldCount(); //this comes up with the correct number, so AX is aware of the right number //DID NOT WORK EITHER common = workingQuery.dataSourceNo(i).getNo(); common = queryRun.get(workingQuery.dataSourceNo(i).table()); dicttable = new DictTable(common.TableId); fieldcnt = dicttable.fieldCnt(); //parse through the fields and set the values in the new table for (i = 1; i <= fieldcnt; i++) { //write the field names and values fieldid = dicttable.fieldCnt2Id(i); dictfield = new dictfield(common.TableId,fieldid); info(dicttable.fieldName(fieldid)); info(common.(dictfield.id())); } } }
You need to iterate the system class QueryBuildFieldList using
fieldCount
andfield
methods. Also check Axaptapedia.