D365 Finance & Operations and Dynamics AX Forum

Expand all | Collapse all

D365FO - Merge "query used when the form first opens" and "custom query". in x++

  • 1.  D365FO - Merge "query used when the form first opens" and "custom query". in x++

    Posted May 20, 2020 09:55 AM
    Hello everyone,

    I hope everyone is healthy.I want to ask you something please.

    I have a workspace working with a query object.user can add quick filter to grid in this workspace.
    and then he/she can process the record.
    I don't want to lose custom filter after processed.
    I want to merge "query used when the form first opens" and "custom query".

    For example:


    initQuery = WebshopIntegrationSalesLine_DS.query();

    {Query WebshopIntegrationSalesLineQuery object 247e060: SELECT FORUPDATE * FROM WebshopIntegrationSalesLine(WebshopIntegrationSalesLine) USING INDEX SalesLineOperationIdx WHERE ((Processed = 0)) JOIN FORUPDATE * FROM SalesLine(SalesLine) ON WebshopIntegrationSalesLine.SalesLine = SalesLine.RecId JOIN FORUPDATE * FROM SalesTable(SalesTable) ON SalesLine.SalesId = SalesTable.SalesId OUTER JOIN FORUPDATE InventTransId FROM SalesLine(Ref_SalesLine_SalesLineRelation) ON WebshopIntegrationSalesLine.SalesLine = SalesLine.RecId} Dynamics.AX.Application.Query

    customQuery  = WebshopIntegrationSalesLine_DS.queryRun().query();

    {Query WebshopIntegrationSalesLineQuery object 9195690: SELECT FORUPDATE * FROM WebshopIntegrationSalesLine(WebshopIntegrationSalesLine) USING INDEX SalesLineOperationIdx WHERE ((Processed = 0)) JOIN FORUPDATE * FROM SalesLine(SalesLine) ON WebshopIntegrationSalesLine.SalesLine = SalesLine.RecId JOIN FORUPDATE * FROM SalesTable(SalesTable) ON SalesLine.SalesId = SalesTable.SalesId OUTER JOIN FORUPDATE InventTransId FROM SalesLine(Ref_SalesLine_SalesLineRelation) ON WebshopIntegrationSalesLine.SalesLine = SalesLine.RecId WHERE ((SalesLine(Ref_SalesLine_SalesLineRelation).InventTransId = N'L-0000021238'))} Dynamics.AX.Application.Query

    I use the following method to merge two queries;
    SysQuery::mergeRanges(customQuery, initQuery);
    SysQuery::mergeFilters(customQuery, initQuery);


    It triggered before the super(i tried after super()) in executeQuery method in the form's datasource.it is not getting errors but losing custom filters.

    Anyone have any idea about this?Thank you for your suggestions .

    Best Regards,
    Secil.




    ------------------------------
    Secil Tuncoz
    Fahrrad XXL Group
    Frankfurt am Main
    ------------------------------
    Academy - Online Interactive Learning from Experts


  • 2.  RE: D365FO - Merge "query used when the form first opens" and "custom query". in x++

    SILVER CONTRIBUTOR
    Posted May 22, 2020 06:07 PM
    Have a look at the below link with an example explaining how to merge queries and see if this helps:

    http://santoshkmrsingh.blogspot.com/2019/09/merge-queries.html

    Would also suggest if the above link doesn't help to put out your question at Dynamics Community


    ------------------------------
    Shilpi Thakur
    Freelance AX/D365 Microsoft Consultant
    Dynact Consulting Ltd
    ------------------------------

    Academy - Online Interactive Learning from Experts


If you've found this thread useful, dive deeper into User Group community content by role