General X++ Development

How do I get records from a QueryRun in X++?

Asked by Sunny Vasty· Aug 13, 2026· 1 answers

How do I get records from a QueryRun in X++?

SSunny Vasty75 reputation · answered Aug 13, 2026

Call next() to advance the query and get() to retrieve the buffer for a datasource.

X++
QueryRun queryRun = new QueryRun(query);

while (queryRun.next())
{
    CustTable custTable = queryRun.get(tableNum(CustTable));

    info(custTable.AccountNum);
}

For multi-datasource queries, call get() with the table ID for the datasource buffer you need.