Brad
Brad

Reputation: 1369

Hoiw to get the selection fields of a query

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,

Upvotes: 0

Views: 5391

Answers (1)

Jan B. Kjeldsen
Jan B. Kjeldsen

Reputation: 18051

You need to iterate the system class QueryBuildFieldList using fieldCount and fieldmethods. 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

Related Questions