Counting the number of records in a QueryRun
When you want to count the number of records that are currently displayed on a form, and you have only one data source, just call the static method countTotal() from the SysQuery-class.
public void executeQuery() { ; super(); info(int2str(SysQuery::countTotal(EmplTable_ds.queryRun()))); }
But when you want to do the same when you joined multiple data sources, you will actually have to loop trough the whole selection. You can do this easily by calling countLoops() on the SysQuery-class. Keep in mind that this has a serious influence on your performance.
public void executeQuery() { ; super(); info(int2str(SysQuery::countLoops(EmplTable_ds.queryRun()))); }
Tags: Dynamics AX, Forms, Performance, Programming, Query, QueryRun, X++
This entry was posted on Tuesday, March 9th, 2010 at 08:00 and is filed under Dynamics AX. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

