Skip to main content

Notifications

Announcements

No record found.

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

How to pass temporary table from form to another?

Posted on by 920

I pass a temporay table from  form A : 

 select * from browsedmenuItemsTmp where browsedmenuItemsTmp.MatrixRole == matrixRole.MatrixID;
        args.record(browsedmenuItemsTmp);
        args.parm(matrixRole.MatrixID);

        args.name(formstr(form B));
        formRun        = ClassFactory.formRunClass(args);
        formRun.init();
        formRun.run();
        formRun.wait();

in the form B , I add the temporary table in datasource and I add this code in the init method of from B:

    parmid   = element.args().parm();
    browsedMenuItemsTmp = element.args().record();
    query                    = new Query();
    queryBuildRange1         = query.addDataSource(tablenum(MenuItemTmp)).addRange(fieldnum(MenuItemTmp,MatrixRole));
    queryBuildRange1.value(parmid);
    MenuItemTmp_ds.query(query);

But I don't get any values in the form B

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to pass temporary table from form to another?

    Then most likely your MultiSelectionHelper is attached to the wrong data source.

    Please double check that the DS of your grid is really called MenuItemTmp_ds (which is the one that you use with MultiSelectionHelper).

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to pass temporary table from form to another?

    yes, I means that multiselectionhelper returns  only the first(on the top of the grid) record of your grid.

    I have 2 datasources .

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to pass temporary table from form to another?

    What do you mean "always I get first record"?

    Do you mean that multiselectionhelper returns you only the first (on the top of the grid) record of your grid? Or something else?

    Do you have many data sources in your form? Are you sure that the grid and the multiselectionhelper are using the same data source?

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to pass temporary table from form to another?

    Yes now I can see all record of tmp table : 

    7144.grid.png

    But When I select record always I get the first record:

       MultiSelectionHelper     selectionHelper = MultiSelectionHelper::construct();
       selectionHelper = MultiSelectionHelper::construct();
       selectionHelper.parmDataSource(MenuItemTmp_ds);
       browsedMenuItems = selectionHelper.getFirst();
    
            while (browsedMenuItems)
            {
                browsedMenuItems = selectionHelper.getNext();
            } 
            

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to pass temporary table from form to another?

    What do you mean that you can't get selected record from the grid?

    Do you now see the temp table records in the grid of form B?  

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to pass temporary table from form to another?

    Thanks Nikoloas,

    I can now get the values from tmp table

    I stock values in this table on form B using the insertRecord method then I call it in the init method of form B .

    But now I can't get selected record from grid which has tmp table as datasource. 

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to pass temporary table from form to another?

    I would try to split the problem in many pieces.

    1) Sending temp table pointer from place A to place B. Please make sure that you have data in your temp table pointer. Also, if you use args.record() it passes only one record so that's not the way to pass a temp table pointer (of many records). Instead you could use args.object to pass it.

    2) Using temp table as form data source. It seems that you are not setting the temp table correctly as data source of form B. Have you used temp tables as form data sources before? The detailed solution depends if you use InMemory or TempDB table so please try to search articles for your case.

    3) I always suggest launching forms via menu items (using MenuFunction class), this way the security framework of AX is used (it doesn't open the form if your user doesn't have access to the menu item via privileges).

    Does this help? If not, please share more details about which part is not working, and also your updated code. Thanks!

  • Suggested answer
    Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: How to pass temporary table from form to another?

    Hi BASMA,

    After the queryRun is initialized on form B and temp datasource added you need to indicate which temp cursor to use with setRecord method.

    this.queryRun().setRecord(browsedMenuItemsTmp)

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

Product updates

Dynamics 365 release plans