Using query Statistics total record of Row on the Form
Sometimes customer want to know how many records in that Form.(include user query or filter condition) .
Well.Such as below X++ Code:
Wrote by Jimmy on April 21th on 2011
display int64 recCount()
{
//this method maybe replace under the datasource method(must be specify datasource) or Form method
QueryRun qrCount;
QueryBuildDataSource qbsCount;
DictTable dictTable;
DictField dictField;
int64 rowCount;
Common common;
;
//qrCount = new QueryRun(this.queryRun().query().pack());//datasource method
qrCount = new QueryRun(QVS_POJournalTable_ds.queryRun().query().pack());//Form method or datasource method
qbsCount = qrCount.query().dataSourceNo(1);
dictTable = new DictTable(qbsCount.table());
qbsCount.orderMode(orderMode::GroupBy);
qbsCount.addSelectionField(dictTable.fieldName2Id("RecId"),SelectionField::Count);
//..... add table relation and one of filtering field
while (qrCount.next())
{
common = qrCount.getNo(1);
rowCount = any2int(common.RecId);
}
return rowCount;
}

浙公网安备 33010602011771号