Reputation: 1369
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()));
}
}
}
Upvotes: 0
Views: 5391
Reputation: 18051
You need to iterate the system class QueryBuildFieldList using fieldCount
and field
methods. Also check Axaptapedia.
Query q = new Query(queryStr(CustTable));
QueryBuildDataSource qbds = q.dataSourceTable(tableNum(CustTable));
QueryBuildFieldList qbfl = qbds.fields();
Counter i;
for (i = 1; i <= qbfl.fieldCount(); i++)
info(new DictField(qbds.table(), qbfl.field(i)).name());
Upvotes: 1