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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

edit a query in a list page form but the filter is not use

(0) ShareShare
ReportReport
Posted on by

Hi all,

I need to add a few criteria to a query in the listpageform, and prompt the user for criteria and then send that input to the datasource to executing my query. I have override the initializeQuery() like following:

public void initializeQuery(Query _query)

{

   QueryRun           qr;

   SMAAgreementLine   smaAgreementLine;

   FormDataSource formDataSource = new FormDataSource();

 

    _query.dataSourceNo(1).addRange(fieldNum(smaAgreementLine, Suspended)).value(SysQuery::valueUnlimited());

   qr = new QueryRun(_query);

 

   if(qr.prompt())

   {

       _query = qr.query();

   }

   super(_query);

}

After that open the form and change the filter to Service agreement "00001", click ok. But the result is not applied the new filter( the result is still SysQuery::valueUnlimited() filter).

We cannot send the user's input to datasource and execute the new filter.

Filter_2D00_picture1.pngfilter_2D00_picture2.png

 

After debugging, I found the query has been actually changed but not execute. Could you please help me? Thank you very much.

Query Repro_ServiceAgreementLineQuery object 1cbda3d0: SELECT * FROM SMAAgreementLine(SMAAgreementLine_1) WHERE ((AgreementId = N'00001')) JOIN * FROM SMAAgreementTable(SMAAgreementTable_1) ON SMAAgreementLine.AgreementId = SMAAgreementTable.AgreementId JOIN * FROM ProjTable(ProjTable_1) ON SMAAgreementTable.ProjId = ProjTable.ProjId JOIN * FROM ProjInvoiceTable(ProjInvoiceTable_1) ON ProjTable.ProjInvoiceProjId = ProjInvoiceTable.ProjInvoiceProjId JOIN * FROM ProjFundingSource(ProjFundingSource_1) ON ProjInvoiceTable.ProjInvoiceProjId = ProjFundingSource.ContractId OUTER JOIN Person, Person FROM HcmWorker(Ref_HcmWorker_HcmWorker) ON SMAAgreementLine.Worker = HcmWorker.RecId OUTER JOIN Name, RecId FROM DirPerson(Ref_DirPerson_HcmWorker_DirPerson_FK) ON HcmWorker.Person = DirPerson.RecId

*This post is locked for comments

  • Rustem Galiamov Profile Picture
    8,072 on at

    Hi Ben_Liu!

    Where you've created the initializeQuery() method?

  • Community Member Profile Picture
    on at

    Hi Rustem,

    Not the method in SMAAgreementTableListPageInteraction class, Actually I created a custom ListPage and use SMAAgreementList table as the example. I want the users to be prompted initially before loading the form with a query filter so I can enter in a value and get a filtered list initially. I used the initializeQuery class on the list page class.

    filter1.PNG

  • Rati Sharabidze Profile Picture
    612 on at

    Hello,

    For simplicity, you can check how it work on Voucher transactions form in GL.

    Just put a break point in the init method of the form SysQueryForm to get the stack trace.

    BR

  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Try the following:

    1. Remove initializeQuery() method.

    2. Add range to your query datasource table.

    3. In run() method of your form add the code which call prompt. (as example take a look at InventOnHandItemListPage form and InventOnHandDim query).

  • Verified answer
    Community Member Profile Picture
    on at

    I found the answer to my issue, It should let the formdatasource in SMAListPage to execute the new query rather
    than only update the value of _query. I forget to let the FormDataSource to run with the new filter. Here is the update code:

    public void initializeQuery(Query _query)
    {
        QueryRun            qr;
        SMAAgreementLine    smaAgreementLine;
        FormDataSource      formDataSource;
        Form smaListPage = new Form(FormStr(SMAListPage));
    
    
        //_query.dataSourceNo(1).addRange(fieldNum(smaAgreementLine, Suspended)).value('1');  //working
        _query.dataSourceNo(1).addRange(fieldNum(smaAgreementLine, Suspended)).value(SysQuery::valueUnlimited());
    
        qr = new QueryRun(_query);
    
        if(qr.prompt())
        {
            _query = qr.query();
            formDataSource = this.listPage().activeRecord(smaListPage.dataSource(1).name()).dataSource();
            formDataSource.query(_query);
        }
        super(_query);
    }
    


    Thanks to everyone who pitched on this problem.

  • Suggested answer
    startax Profile Picture
    1,845 on at

    Hi,

    Suspended field is NOYES enum that always have value in table 0 or 1. So give range either No or Yes or both 

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Prashant Singh Profile Picture

Prashant Singh 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans