web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Filter Report by Year (Data is TransDate)

(0) ShareShare
ReportReport
Posted on by

Hi,

i have a report created through RDP (Query + Class)

i didnt bother using Contract Class because i can set the Range in the Query (my current Range is AccountNum). 

every thing is working fine. and i already run it.
------ 

but now, there's additional...

i have to add:  Filter by Year (the data has TransDate which is Full Date)

how can i manage to put the Range/Filter in my RDP Class ?

as much as possible, i dont want to use Contract/Controller and keep it in simple RDP (processReport). so im asking for answers here.

please help, thanks.

*This post is locked for comments

I have the same question (0)
  • Sohaib Cheema Profile Picture
    48,663 User Group Leader on at
    RE: Filter Report by Year (Data is TransDate)

    if you don't want to use contract class, you can simple go inside RDP and modify query before if it run.

    adding range should be same as we do in normal x++ queries.

    Contract class just creates parameters and shows those to user, where user can do section.

    "Not having a contract class" will not stop you for adding ranges.

  • Community Member Profile Picture
    on at
    RE: Filter Report by Year (Data is TransDate)

    Hello Sohaib.

    this is my processReport code:

    my Query is already Arranged in a Query object(not in code)

    so i dont know where to put the Code and what to Code to Set a Year Parameter

    help pls.

     public void processReport()

    {

       Query                   query;

       QueryRun                queryRun;

       QueryBuildRange         queryBuildRange;

       QueryBuildDataSource    queryBuildDataSource;

       VendTrans                               vendTrans;

       GeneralJournalEntry                     generalJournalEntry;

       GeneralJournalAccountEntry              generalJournalAccountEntry;

       MainAccount                             mainAccount;

       query = this.parmQuery();

       queryRun = new QueryRun(query);

       ttsBegin;

       while (queryRun.next())

       {

           vendTrans                           = queryRun.get(tableNum(VendTrans));

           generalJournalEntry                 = queryRun.get(tableNum(GeneralJournalEntry));

           generalJournalAccountEntry          = queryRun.get(tableNum(GeneralJournalAccountEntry));

           mainAccount                         = queryRun.get(tableNum(MainAccount));

           expTmp.TransDate            = vendTrans.TransDate;

           expTmp.AccountNum           = vendTrans.AccountNum;

    .........

    expTmp.insert();

    }

    ttsCommit;


    }

  • Sohaib Cheema Profile Picture
    48,663 User Group Leader on at
    RE: Filter Report by Year (Data is TransDate)

    put your range between these two line of code

    query = this.parmQuery();

    //here should be your range i.e. before running query and after getting query

    queryRun = new QueryRun(query);

  • Martin Dráb Profile Picture
    236,279 Most Valuable Professional on at
    RE: Filter Report by Year (Data is TransDate)

    Also notice my reply to your duplicate thread on DUG forum.

  • Community Member Profile Picture
    on at
    RE: Filter Report by Year (Data is TransDate)

    if you use .addrange in code, will there be also a textbox to change the filter when you run the report?

    and how can i filter it by year?, i only know how to filter in range of date.

    is this correct:

    query = this.parmQuery();

       qbds = query.dataSourceName(identifierStr(vendTrans));

       qbds.addRange(fieldNum(vendTrans, TransDate)).value(queryRange(31\1\2014, 5\2\2014));

       queryRun = new QueryRun(query);

    please correct my code. thanks

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Filter Report by Year (Data is TransDate)

    The simplest way to do this is by adding range on Trans Date spanning whole year like if you want data from 2015 then it would be like

    qbr_Transdate.value(strfmt("1/1/2015..12/31/2015"));

    Now how you do it actually concerns me.  If I had to filter data on RDP level I would go with Contract and Controller. They are not as scary as I assume you think.

    Or perhaps you can let all the data flow to your report and then add a filter on the SSRS report itself.

    Hope my suggestions help you.

    Thanks,

    Jahan Zaib

  • Verified answer
    Martin Dráb Profile Picture
    236,279 Most Valuable Professional on at
    RE: Filter Report by Year (Data is TransDate)

    No, there won't be any change in UI if you just add a filter in your RDP class. That's what data contract and UI builder are for.

    You can have a year (= number) in your data contract and convert it to the range of dates in your RDP class.

  • Sohaib Cheema Profile Picture
    48,663 User Group Leader on at
    RE: Filter Report by Year (Data is TransDate)

    add two variables at top of your method as below

    TransDate _fromDate,_toDate;

    _fromDate = mkdate(1,1,year(today()));

    _toDate = mkdate(31,12,year(today()));

    then pass it as range in your query such as under

    query.addDataSource(tablenum(vendTrans)).addRange(fieldnum(vendTrans,TransDate)).value(queryRange(_fromDate,_toDate));

  • Community Member Profile Picture
    on at
    RE: Filter Report by Year (Data is TransDate)

    i used Martin's Suggestion, made a Year Contract, then converted it to range in RDP. thanks all.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Guy Terry Profile Picture

Guy Terry 2 Moderator

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans