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

Multi select lookup form store value in the control

(0) ShareShare
ReportReport
Posted on by

Hi All,

I created a form (pattern : lookup basic)

And assign  the form to the string control. 

pastedimage1627461356759v1.png

[FormControlEventHandler(formControlStr(EcoResProductDetailsExtended, InventTable_KT_Occasions), FormControlEventType::Lookup)]
public static void InventTable_KT_Occasions_OnLookup(FormControl sender, FormControlEventArgs e)
{
Args args;
FormRun formRun;
SysLookupMultiSelectGrid multiSelectGrid;
FormStringControl d = sender.formRun().design().controlname(formControlStr(EcoResProductDetailsExtended,InventTable_KT_Occasions));

FormControlCancelableSuperEventArgs event = e as FormControlCancelableSuperEventArgs;
//Add the categorymultiselectlookupfilter as an argument for lookup
args = new args(formStr(categorymultiselectlookupfilter));
//Add the current conrol (Grid Column) as lookup caller
args.caller(d);

formRun = classFactory.formRunClass(args);
//Initialize and perform lookup form
formRun.init();

d.performFormLookup(formRun);
//formRun.wait();


event.CancelSuperCall();

}

I can select multiple values but the values not get stored in string control.

How to get and seth the values to the string control

I have the same question (0)
  • Community Member Profile Picture
    on at

    The string control is the unbounded control

  • huijij Profile Picture
    19,811 on at

    Hi john,

    Did the method of multiselectctrl.getSelectedfieldvalue() work?

    Please refer the old thread:

    community.dynamics.com/.../703018

    regards

  • Community Member Profile Picture
    on at

    Hi Judy,

    Thanks for the reply.

    I didnt use the SysLookupMultiSelectCtrl for lookup.

    I just assign my form to that string control (onlookup event handler) as i mentioned in the code.

    How to get the seleted values in that form.

  • Verified answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    First of all, let's add line indentation to your code, because it's difficult to read without indentation. Please use Insert > Insert Code to paste source code in future. I've also simplified your code a little bit:

    [FormControlEventHandler(formControlStr(EcoResProductDetailsExtended, InventTable_KT_Occasions), FormControlEventType::Lookup)]
    public static void InventTable_KT_Occasions_OnLookup(FormControl sender, FormControlEventArgs e)
    {
    	FormStringControl d = sender.formRun().design().controlname(formControlStr(EcoResProductDetailsExtended, InventTable_KT_Occasions));
    
    	//Add the CategoryMultiSelectLookupFilter as an argument for lookup
    	Args args = new Args(formStr(CategoryMultiSelectLookupFilter));
    	//Add the current control (Grid Column) as lookup caller
    	args.caller(d);
    
    	FormRun formRun = classFactory.formRunClass(args);
    	//Initialize and perform lookup form
    	formRun.init();
    
    	d.performFormLookup(formRun);
    
    	FormControlCancelableSuperEventArgs event = e as FormControlCancelableSuperEventArgs;
    	event.CancelSuperCall();
    }

    Why exactly don't you want to use SysLookupMultiSelectCtrl? It seems that you're trying to implement the same thing and you even don't know how, therefore using the already available solution would make sense to me.

    Also, assigning an individual form control as the caller looks strange.

  • ergun sahin Profile Picture
    8,826 Moderator on at

    I have never used it this way. At worst, at your lookup form's close  methods. It can be parmed back to first form, but it should be resolved without the need for it.

    There is a method called "d.getSelection()". I think its return a container. Can you check what's in it?

    Also, I'm asking because I'm curious. Does the structure work when you select single instead of multiple?

  • Community Member Profile Picture
    on at

    Thank you for your reply Ergun,

    pastedimage1627472288490v1.png

    d.getselection() return object[0].

    Even i select single value its not storing on string control.

    How to set values to the form string control?

  • Community Member Profile Picture
    on at

    Thank you Drab for the for the suggestions (Insert Code to paste source code).

    Why i not use the SysLookupMultiSelectCtrl is i need to have quick filter for the lookup.

    So i design the form and assign it to the string control.

  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    A good approach may be looking at how Microsoft has solved the problem in the standard code (e.g. SysLookupMultiSelectGrid class).

    If you want to design your own solution from scratch, note that you can utilize MultiSelectionHelper to class to itrerate records selected in your lookup form.

  • Community Member Profile Picture
    on at

     [FormControlEventHandler(formControlStr(EcoResProductDetailsExtended, InventTable_KT_Occasions), FormControlEventType::Lookup)]
        public static void InventTable_KT_Occasions_OnLookup(FormControl sender, FormControlEventArgs e)
        {
            Args args;
            FormRun formRun;
            MultiSelectionHelper Msh;
            KT_EdibleProductOccasionsTable localTable;
            FormDataSource              inventTableLoc_ds = sender.formRun().dataSource(formDataSourceStr(EcoResProductDetailsExtended, InventTable));
            InventTable                 inventTableLocal = inventTableLoc_ds.cursor();
            str store;
            FormStringControl d = sender.formRun().design().controlname(formControlStr(EcoResProductDetailsExtended,InventTable_KT_Occasions));
            FormDataSource occasions_ds;
            FormControlCancelableSuperEventArgs event = e as FormControlCancelableSuperEventArgs;
            //Add the categorymultiselectlookupfilter as an argument for lookup
            args = new args(formStr(categorymultiselectlookupfilter));
            //Add the current conrol (Grid Column) as lookup caller
            args.caller(d);
           
            formRun = classFactory.formRunClass(args);
            //Initialize and perform lookup form
            formRun.init();
    
            d.performFormLookup(formRun);
            formRun.wait();
            if(formRun.closedOk())
            {
                occasions_ds = formRun.dataSource();
               // occasions_ds.mark();
                Msh = MultiSelectionHelper::construct();
                Msh.parmDatasource(occasions_ds);
                //localTable = Msh.getFirst();
                //While(localTable)
                //{
                for (localTable = occasions_ds.getFirst(true) ? occasions_ds.getFirst(true) : occasions_ds.cursor();localTable;
                localTable = occasions_ds.getNext())
                    {
                    store  = localTable.KT_Occasions ";";
                   
                   // localTable = Msh.getNext();
                }
                d.text(store);
                
                inventTableLocal.KT_Occasions = d.valueStr();
                inventTableLocal.write();
                inventTableLoc_ds.reread();
                inventTableLoc_ds.refresh();
            }
    
           
            event.CancelSuperCall();
    
        }
    

    Thank you Martin for this way of approach.

    Now i can store the values in the string control.

    Now the problem is after select multiple values from the lookup again i click the dropdown there is no values get selected in the lookup.

    pastedimage1627534315381v1.png

    The selected values are un selected i need to select from the start.

    How can i fix this issue ?

  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    I don't know how to do that and I wouldn't try to reinvent the wheel anyway. Look into the standard solution and reuse it, or - if reusing in place isn't possible - copy it to your own class.

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

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans