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

Community site session details

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

How to deal with multiselecthelper on clicked event ?

(0) ShareShare
ReportReport
Posted on by 229

Hey friends,

I'm looking for some help.

I got Two forms A and B.

On form A i got some grid with raws and it values.

I want to select one or more raws and when i click on form A button i will reach form B.

This form B need to be feed by the raws i selected before on form A.

I tried this code :

 [FormControlEventHandler(formControlStr(EUKShowDetailsItemsForm, EUKLevelModifier), FormControlEventType::Clicked)]
    public static void EUKLevelModifier_OnClicked(FormControl sender, FormControlEventArgs e)
    {
        Args args = new Args();
        FormRun formRun, callerFormRun;
        //EUKSecurityTreeNode EukSecurityTreeNode;

        FormDataSource    EUKShowDetailsItemsForm_DS = sender.formRun().dataSource(formDataSourceStr(EUKShowDetailsItemsForm, EUKSelectedMenus));

        MultiSelectionHelper    selectionHelper = MultiSelectionHelper::construct();
        EUKSelectedMenus    eukSelectedMenus;


        selectionHelper.parmDataSource(EUKShowDetailsItemsForm_DS);


        
        args.name(formstr(EUKModifyMenuItemsAccessLevel)); // Assign to args form parameters
        
        formRun = classfactory.formRunClass(args);

        eukSelectedMenus  = selectionHelper.getFirst();

        if (eukSelectedMenus.RecId)
        {
            while (eukSelectedMenus.RecId != 0)
            {
                eukSelectedMenus = selectionHelper.getNext();
            }
        }
        //eukSelectedMenus = sender.formRun().dataSource().cursor(); //Get row values from row selected
        args.record(eukSelectedMenus); //Assign to args values
        formRun.init();
        formRun.run();
        formRun.detach();
    }

The loop worked but args didnt register raws values.

Thanksfully.

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    236,919 Most Valuable Professional on at
    RE: How to deal with multiselecthelper on clicked event ?

    Do it differently. Instead of opening the form through code in clicked(), use a menu item button. And set EUKShowDetailsItemsForm to its Data Source property.

    Then override init() method of EUKShowDetailsItems form, get a reference to the caller data source and use it in MultiSelectionHelper. For example:

    FormDataSource callerDataSource = FormDataUtil::getFormDataSource(this.args().record());
    if (callerDataSource)
    {
    	MultiSelectionHelper selectionHelper = MultiSelectionHelper::construct();
    	selectionHelper.parmDataSource(callerDataSource);
    	
    	...
    }

  • Awaxx Profile Picture
    229 on at
    RE: How to deal with multiselecthelper on clicked event ?

    Hello goshoom

    Could you explain it to me please i'm real newbie and still need to be teach ?

    What the difference, is it for best practice or is there a performance gain ?

    Thanksfully.

  • Martin Dráb Profile Picture
    236,919 Most Valuable Professional on at
    RE: How to deal with multiselecthelper on clicked event ?

    You should use menu items instead of code whenever possible. It has several reasons:

    • It ensures consistency. For example, you set a label on the menu item, and maybe other properties such as an enum parameter, and it applies everywhere where you use the menu item. (Of cource, you can override the label in a particular form if needed.)
    • The system will apply permissions configured for this menu item. That's important.
    • The best code is the one that you don't have to write, test and maintain, therefore if no code is needed to open a form, you shouldn't write it. Let the system do the work for you.
  • Awaxx Profile Picture
    229 on at
    RE: How to deal with multiselecthelper on clicked event ?

    Thank you for that explaination. I will try your idea and come back soon.

  • Awaxx Profile Picture
    229 on at
    RE: How to deal with multiselecthelper on clicked event ?

    Hey goshoom ,

    If i choose your way and i want to filter with a query, how could i do it ?

    Imagine i overide the init method on EUKShowDetailsForm (Form A) and i grab my multiselection values.

    This selection will give me some values that i need to make some comparison on form B to feed it with the good field values.

    The query should be overiden on this form B as "Execute Query" method or on form A ?

    I m a bit lost honestly.

    Thanksfully.

  • Verified answer
    Martin Dráb Profile Picture
    236,919 Most Valuable Professional on at
    RE: How to deal with multiselecthelper on clicked event ?

    If you want to filter data in form A, change the query in form A. If you want to filter data in form B, change the query in form B.

    executeQuery() gets called every time when you refresh the form and I'm not really sure that it's the right place. It all depends on what exactly you want to do.

  • Awaxx Profile Picture
    229 on at
    RE: How to deal with multiselecthelper on clicked event ?

    goshoom 

    What i wanna do is simple.

    I will first select row from form A and that rows will contain some values

    That values like "id" will be compare to form B which it feed by another datasource and that comparison will give me other values to display on form B.

  • Martin Dráb Profile Picture
    236,919 Most Valuable Professional on at
    RE: How to deal with multiselecthelper on clicked event ?

    Can you elobrate it, please?

    You have an ID. What you will do with it? Do you want to find records in the table used for the data source in Form B that has the same value in a certain field?

  • Awaxx Profile Picture
    229 on at
    RE: How to deal with multiselecthelper on clicked event ?

    Hi goshoom 

    There is similar fields like "matrix id" and "label name".

    So what i want to do is to feed other fields where "matrix id" and "label name" from form A == to form B

  • Martin Dráb Profile Picture
    236,919 Most Valuable Professional on at
    RE: How to deal with multiselecthelper on clicked event ?

    A grid is based on data sources, and a data sources gets data from a query, which loads some data from a table. Therefore you should focus on what database query you want to create.

    Saying things like "from form A == to form B" isn't really helpful, because it says little about which data you want to fetch from database.

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

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

#1
André Arnaud de Calavon Profile Picture

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

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 569

#3
Martin Dráb Profile Picture

Martin Dráb 551 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans