X++ code to Count Records in Query

Following code illustrates how we can use SysQuery::countTotal() method to get the number of records in Query.

static void Query_cntRecords(Args _args)
{
    Query                query = new Query();
    QueryRun             queryRun;
    QueryBuildDataSource qbd;
    ;
   
    qbd = query.addDataSource(tablenum(CustTable));
    queryRun = new QueryRun(query);
   
    info(strfmt("Total Records in Query %1",SysQuery::countTotal(queryRun)));
   
}

3 comments:

  1. hi nagaraj

    My name is mani i am new to ax i would like to get the shipping qty and weight of an sales order after posting an invoice. which table should i have to look into is it the salesshippingstat.

    Thanks and Regards

    ReplyDelete
  2. Hi ,

    You can find it in SalesShippingStat Table.
    Take any salesOrder with Invoiced status.
    Click on Inquiries==>Invoice.
    In Invoice form you will find Shippments button.clicl on it , if any shippments it will show.

    While posting salesInvoice ,you have option to enter shipments.

    ReplyDelete
  3. Hi Nag,
    This is manjula S. I was jst searching for count of records in a queryrun object.... Awesome your blog helped me.

    Excellent blog.... Keep blogging

    ReplyDelete

Note: Only a member of this blog may post a comment.