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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to pass temporary table from form to another?

(0) ShareShare
ReportReport
Posted on by 932

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

I have the same question (0)
  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    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)

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    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!

  • BASMA Profile Picture
    932 on at

    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. 

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    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
    932 on at

    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
    101,160 Moderator on at

    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
    932 on at

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

    I have 2 datasources .

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    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).

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans