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

Multi select column in Sales Table form.

(0) ShareShare
ReportReport
Posted on by 113

28501.Capture.PNG

[Extensionof(formstr(SalesTable))]
final class SalesLine_CAP_Extension
{  

    [FormControlEventHandler(formControlStr(SalesTable, SalesLine_ManufacturingPlant_CAP), FormControlEventType::Lookup)]
    public static void SalesLine_ManufacturingPlant_CAP_OnLookup(FormControl sender, FormControlEventArgs e)

    {
        Args args;
        FormRun formRun;
        MultiSelectionHelper Msh;
        InventSite inventSite;
        FormDataSource              salesLine_ds = sender.formRun().dataSource(formDataSourceStr(SalesTable, SalesLine));
        SalesLine                 salesLine = salesLine_ds.cursor();
        str store;

        int                                  i, conLength;
        int64                                recId;
        SysLookupMultiSelectValues           delimitedControlValues;
        container                            controlValues;
        container                            selectField;

        FormStringControl d = sender.formRun().design().controlname(formControlStr(SalesTable, SalesLine_ManufacturingPlant_CAP));
        FormDataSource inventSite_ds;
        FormControlCancelableSuperEventArgs event = e as FormControlCancelableSuperEventArgs;
        //Add the categorymultiselectlookupfilter as an argument for lookup
        args = new args(formStr(InventSite));
        //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);
        inventSite_ds = formRun.dataSource();       
        delimitedControlValues = d.text();      
        if(delimitedControlValues)
        {
            controlValues = str2con(delimitedControlValues, ';', false);
            conLength = conlen(controlValues);
            for (i = 1; i <= conLength; i  )
            {
                
                inventSite_ds.findRecord(InventSite::find(conpeek(controlValues, i)));
                inventSite_ds.mark(true);
              
            }
        }
       

        formRun.wait();
        if(formRun.closedOk())
        {
            Msh = MultiSelectionHelper::construct();
            Msh.parmDatasource(inventSite_ds);

            for (InventSite = inventSite_ds.getFirst(true) ? inventSite_ds.getFirst(true) : inventSite_ds.cursor();inventSite;
            InventSite = inventSite_ds.getNext())
            {
                store  = InventSite.SiteId ";";
            }
            d.text(store);
            
            SalesLine.ManufacturingPlant_CAP = d.valueStr();
            SalesLine.write();
          //  SalesLine.reread();
           // SalesLine.refresh();
         }

       
        event.CancelSuperCall();

    }

}
       
Hi,
I have written a code for a Multiselect column(ManufacturingPlant_CAP) - In data source  (Sales Line).- In Form (Sales Table).
and I want to get the value from Table(InventSite) - Column(SiteID).
But I am getting form open Like as in the picture attached and also not able to select multiple fields.

Can Anyone Suggest.

I have the same question (0)
  • Vignesh.A Profile Picture
    203 on at
    RE: Multi select column in Sales Table form.

    Hi Harish,

    From your code, I understand that, you are opening the Invent site form through arguments during the lookup method and and try to select multiple records in it.

    But we can have a simple approach to it. Try to use "SysLookupMultiSelectCtrl" class to bring a lookup with multilple record selection options.

    There are many standard forms which uses this class to bring multi select lookup. You can find reference of this class to see how there are being used.

  • HARISH MEHRA Profile Picture
    113 on at
    RE: Multi select column in Sales Table form.

    Thanks for the reply Vignesh.

    I have also used 'SysLookupMultiSelectCtrl' But the result is same. When I am selecting  multi records it is showing like - 0;0 (Zero for each record selected).

  • Verified answer
    Vignesh.A Profile Picture
    203 on at
    RE: Multi select column in Sales Table form.

    Hi Harish,

    We need to tweak the code little bit to get this achieved.

    Below is the sample code similar to your scenario.

    1. Create an extension class for the for the sales table form

    2. make CoC for the form init method

    3. Create a parm method to hold the multilookupSelectCtrl object

    pastedimage1678985367982v1.png

    4. Create an Event Handler class to take the onLookup Event of the form control where the multi select lookup is required.

    5. Write the below code to set the selected value to the field.

    pastedimage1678985532327v2.png

    Below is the result of the code.

    pastedimage1678985653048v3.png

  • HARISH MEHRA Profile Picture
    113 on at
    RE: Multi select column in Sales Table form.

    Thanks Vignesh. It worked.

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

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 398 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans