Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

AOT Query not filtering data through contract class

Posted on by 67

I have created AOT query and used it into RDP. i want to filter data of the AOT query on invoice date so i created contract class and parm methods to filter data. In process report method of RDP i want to create filter on invoice date of the query but it is not working kindly check my code and tell what i am missing in my code.

AOT QUERY

7242.query.png

Contract Class Declaration

contractclassdec.png

startdate.png

enddate.png

RDP Class

dpclassdeclartion.png

tmptableget.png

6746.processreport.png

in visual studio its shows like this 

visulaparam.png

but unable to filter data within date range

emptyreport.png

Kindly help

*This post is locked for comments

  • RE: AOT Query not filtering data through contract class

    thnx Crispin John it worked. Here is the final solution.

    [SysEntryPointAttribute(false)]

    public void processReport()

    {

       Query query;

       QueryRun queryrun;

       QueryBuildRange daterange;

       QueryBuildDataSource qbds;

       ItemWiseSaleContract contract;

       CustInvoiceJour custInvoiceJour;

       CustInvoiceTrans custInvoiceTrans;

       contract = this.parmDataContract() as ItemWiseSaleContract;

       //query = this.parmQuery();

       query = this.parmQuery();

       qbds = query.dataSourceTable(tableNum(CustInvoiceJour));

       daterange = SysQuery::findOrCreateRange(qbds, fieldNum(CustInvoiceJour,InvoiceDate));

       daterange.value(SysQuery::range(contract.parmStartDate(), contract.parmEndDate()));

       //qbds = query.addDataSource(tableNum(CustInvoiceJour));

       //daterange = qbds.addRange(fieldNum(CustInvoiceJour,InvoiceDate));

      // daterange = SysQuery::findOrCreateRange(qbds,fieldNum(CustInvoiceJour,InvoiceDate));

       //daterange.value(strFmt('((InvoiceDate >= %1) && (InvoiceDate <= %2))', date2StrXpp(contract.parmStartDate()), date2StrXpp(contract.parmEndDate())));

       queryrun = new QueryRun(query);

       delete_from ItemWiseSaleTMP;

       while(queryrun.next())

       {

           ItemWiseSaleTMP.clear();

           custInvoiceJour = queryrun.get(tableNum(CustInvoiceJour));

           custInvoiceTrans = queryrun.get(tableNum(CustInvoiceTrans));

           ItemWiseSaleTMP.ItemId = CustInvoiceTrans.ItemId;

           ItemWiseSaleTMP.ItemName = CustInvoiceTrans.Name;

           ItemWiseSaleTMP.InvoiceDate = CustInvoiceJour.InvoiceDate;

           ItemWiseSaleTMP.SalesId = CustInvoiceJour.SalesId;

           ItemWiseSaleTMP.CustAccount = CustInvoicejour.InvoiceAccount;

           ItemWiseSaleTMP.CustName = CustInvoiceJour.invoiceName();

           ItemWiseSaleTMP.Qty = CustInvoiceTrans.Qty;

           ItemWiseSaleTMP.Price = CustInvoiceTrans.SalesPrice;

           ItemWiseSaleTMP.SalesUnit = CustInvoiceTrans.SalesUnit;

           ItemWiseSaleTMP.Amount = CustInvoiceTrans.LineAmount;

          ItemWiseSaleTMP.insert();

       }

    }

  • RE: AOT Query not filtering data through contract class

    why is it still referencing old query what should be the modification in my code ?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans