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

Announcements

No record found.

News and Announcements icon
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 117

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.

  • Vignesh.A Profile Picture
    203 on at

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

    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

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

    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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

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

#1
Martin Dráb Profile Picture

Martin Dráb 426 Most Valuable Professional

#2
CU10121822-0 Profile Picture

CU10121822-0 358

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 353 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans