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

X++ for passing information from Form to New Class using MultiSelectionHelper

(0) ShareShare
ReportReport
Posted on by 95

Currently, we are developing the contents displayed in the Grid of the Form by CSV when clicking Menu Item Button from Add-On Form.

However, there are cases where only the selected lines are output as CSV, so
(MultiSelectionHelper) is used to pass the information of the selected Form to the class that outputs CSV when the button is clicked.
Also, "Onclicked" is used as the event when the button is clicked.


I would like to know specifically how to write the program.
 
pastedimage1592228504577v2.png
I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    In your new class you can access the caller form data source via _args.caller().record().dataSource().

    Then you can launch MultiSeelctionHelper with this data source and fetch the records.

    Is it now clear?

  • keito yokoi Profile Picture
    95 on at

    >In your new class you can access the caller form data source via _args.caller().record().dataSource().

    ⇒ In your new class. Is it an "Onclicked" class? Or is it a class that outputs CSV?

    >Then you can launch MultiSeelctionHelper with this data source and fetch the records.

    ⇒I don't understand this yet.

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

    I mean the class that outputs the CSV. You don't need any "OnClicked" things anywhere. Simply a menu item button that points to your new class.

    About MultiSelectionHelper, did you try to search any information in the web? There's plenty. Just let me know if you need me to find some article.

  • keito yokoi Profile Picture
    95 on at

    Is it okay to write _args.caller().record().dataSource(). as "Table table = _args.caller().record().dataSource()"?

    About MultiSelectionHelper, did you try to search any information in the web? There's plenty. Just let me know if you need me to find some article.

    ⇒

    I would appreciate it if you could give me an article.

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

    No it's not ok to write that and if you would try it you would notice a compiler error. 

    _args.caller().dataSource() returns a FormDataSource object, not a table buffer.

    Also I had a mistake in my example, it's _args.record().dataSource(), not _args.caller().record().dataSource().

    Anyway, here are some results for MultiSelectionHelper: www.google.com/search

    And, when we combine everything we learned so far in this discussion, we will get something like this:

    pubic static void main (Args _args)
    {
        FormDataSource fds = _args.record().dataSource();
        MultiSelectionHelper msh = MultiSelectionHelper::construct();
        msh.parmDataSource(fds);
        
        MyTable myTable = msh.getFirst();
        
        while (myTable)
        {
            info(myTable.MyField);
            myTable = msh.getNext();
        }
    }

  • keito yokoi Profile Picture
    95 on at

    Thank you very much.

    Thanks to you I was able to solve the problem.

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 551 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 278 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans