How to count records in a Query or Form

It seems that when I have a query with more than 1 datasource, the SysQuery::countTotal() will give you the sum of the RecId values of all the records.

example X++ Code

wrote by : Jimmy Oct  12th 2010

in a query

static void Jimmy_queryCountTotal(Args _args)
{
    query                   q = new query();
    queryRun                qr;
    queryBuildDataSource    qbds;
;
    qbds = q.addDataSource(tablenum(VendTable));
    qr = new queryRun(q);
    print sysquery::countTotal(qr);
    //formdatasource.numberOfRowsLoaded();this method Apply for Form
    pause;
}

in a Form

public void executeQuery()
{
;
      super();
      info(int2str(SysQuery::countTotal(VendTable_DS.queryRun())));//this.queryRun())));
      //info(int2str(VendTable_DS.numberOfRowsLoaded()));
}
原文地址:https://www.cnblogs.com/Fandyx/p/1848610.html