Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

How to pass parameter value to SalesTableListPageInteraction class

Posted on by 45

Hi,

I am trying to create my own filter on the salesTableListPage form. I want it to filter by packing slip number. So I have created a small form where the user will enter the packing slip id and click 'OK' and it will show/open the SalesTableListPage form with that sales order. 

I have created a new display menuItem by adding new enum value to the salesTableListPage enum. I have added new IF condition to SalesTableListPageInteraction class > InitializeQuery method as below. When the menuItem is called then open the SalesTableListPage with the query I created inside this method. I tested it by passing static value and it does work. But I want it to capture the value from the form I have created.

Interaction class:

2020_2D00_06_2D00_03-08_5F00_57_5F00_20_2D00_192.168.1.5-_2D00_-Remote-Desktop-Connection.png

My form's clicked method code:

2020_2D00_06_2D00_03-09_5F00_03_5F00_45_2D00_192.168.1.5-_2D00_-Remote-Desktop-Connection.png

The clicked method opens the form but the filter the sales order with the static value i have added to the code. My whole point of asking this question is that how can I pass user value to the InitializeQuery method of the interaction class?

  • pam86 Profile Picture
    pam86 45 on at
    RE: How to pass parameter value to SalesTableListPageInteraction class

    sorry for silly mistakes. it works

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to pass parameter value to SalesTableListPageInteraction class

    Now you have initialized a new Query but not defined what data sources it should have. Then you try to get a data source from that query. It fails because there are no data sources yet. 

    You still need to look closer at Martin's code. Can you see how his first line looks like? 

  • pam86 Profile Picture
    pam86 45 on at
    RE: How to pass parameter value to SalesTableListPageInteraction class

    thank you again, sorry I missed that.

    Now, I have initialized the query but now I get an error about QueryBuildDataSource object not initialized

    2020_2D00_06_2D00_03-12_5F00_55_5F00_53_2D00_192.168.1.5-_2D00_-Remote-Desktop-Connection.png

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to pass parameter value to SalesTableListPageInteraction class

    As the error message says, you haven't initialized the query object so it's null.

    Look at the first line in Martin's code example.

  • pam86 Profile Picture
    pam86 45 on at
    RE: How to pass parameter value to SalesTableListPageInteraction class

    Thank you for the reply Nikolaos and Martin.

    If I add my query and call the menu item from clicked method, it does not execute my query, can you please check if there is something wrong, it fails on "qbds = query......" ?

    2020_2D00_06_2D00_03-10_5F00_12_5F00_34_2D00_192.168.1.5-_2D00_-Remote-Desktop-Connection.png

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,104 Most Valuable Professional on at
    RE: How to pass parameter value to SalesTableListPageInteraction class

    You don't have to modify the form - you can merely pass your query to it:

    Query query = new Query(queryStr(SalesTableListPage));
    
    // Modify the query as needed - this is just an example
    QueryBuildDataSource salesTableDs = query.dataSourceName(tableStr(SalesTable));
    salesTableDs.addRange(fieldNum(SalesTable, CustAccount)).value(queryValue('Cust1'));
            
    Args args = new Args();        
    args.initialQuery(InitialQueryParameter::createByQuery(query));
    
    new MenuFunction(menuItemDisplayStr(SalesTableListPage), MenuItemType::Display).run(args);

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to pass parameter value to SalesTableListPageInteraction class

    In your second screenshot all code related to FormRun is unnecessary and should be removed. When you call MenuFunction().run() you already launch the form.

    In SalesTableListPageInteraction you can get the args by this.listPage().listPageArgs(). Then you can read your value from Args and use it for filtering.

    Another option is to find the correct SalesTable already in your clicked method and put the CustPackingSlipJour in args.record(). This way you would not need to write any code on the form. Not 100% sure if it works but I suggest trying it. Or, try putting the correct SalesTable in args.record().

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,104 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans