Report wizard - Count records functionality

jdemejdeme Member Posts: 12
edited 2008-01-22 in Dynamics AX
Hello everyone.

I have a question which I would assume a lot of other people might have.
A similar question was posted back in 2005 but nobody bothered to answer...

Regarding there report wizard. Customers would like to have the option to display the number of records contained in their ad-hoc report. Currently such a thing does not exist.
I gave it a try to modify the existing classes and display the record count, but not much luck as some classes cannot be modified (e.g. ReportRun).

Any ideas???

Joanna
jdeme

Comments

  • icelanderwillicelanderwill Member Posts: 5
    A report is generated from query. Unfortunately you can not predict the size of the tables inside the query, so you have to iterate through the list.

    In AX 4.0 the wizard has a method which returns the query used for the report, what you can do is in the SysReportWizard class under the reportGenerate method add something like this:
    int                     myCounter = 0;
        QueryRun                myQueryRun;
    
    ...
    query  = this.reportGenerateQuery();
    // new section -->
        myQueryRun = new QueryRun(query);
        while (myQueryRun.next())
        {
            myCounter++;
        }
        info(strfmt("There are %1 record lines in the report", myCounter));
    // new section <--
    

    Then if you open the report wizard, go through the parametrization and click Print preview, you will have a preliminary estimation of how much records are going to be displayed on the report without any criterias.

    You can also put this information in the wizard itself, as you can get the query outside of this code anywhere with reportGenerateQuery(), and count the records there, pass the value to a form control.

    Another thing is if you know you will get all of the records from the table for sure, you can just do this:
    SysDictTable    dt;
        ;
        dt = new SysDictTable(tablename2id("SysUserInfo"));
        info(strfmt("%1", dt.recordCount()));
    
Sign In or Register to comment.