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 SalesTable Form not working.

(0) ShareShare
ReportReport
Posted on by 113

[Extensionof(formstr(SalesTable))]
final class SalesTableMutliselect_Extension
{
    public static SysLookupMultiSelectCtrl        msCtrl;
    
    public void init()
    {
        next init();
        InventSite inventSite;

        ManufacturingPlantCtrl = SysLookupMultiSelectCtrl::construct(this,SalesLine_ManufacturingPlant_CAP, queryStr(InventSiteQuery_CAP));
    }
    

    public Query buildDocuTypeQuery()
    {
        Query       docuTypeQry = new Query(queryStr(InventSiteQuery_CAP));
        return docuTypeQry;
    }
 
    container getSelectedCodes(str ManufacturingPlant_CAP)
    {
        InventSite   inventSite;
        container   tmpValues, conIds;
        int         idx;
     
        if(ManufacturingPlant_CAP)
        {
            tmpValues = str2con(ManufacturingPlant_CAP, ';');
        }
     
        for(idx=1; idx<=conLen(tmpValues); idx  )
        {
            inventSite = InventSite::find(conPeek(tmpValues, idx));
            conIds  = inventSite.SiteID;
        }
        return [conIds];
    }


    [FormDataSourceEventHandler(formDataSourceStr(SalesTable, SalesLine), FormDataSourceEventType::Initialized)]
    public static void SalesLine_OnInitialized(FormDataSource sender, FormDataSourceEventArgs e)

    {
        Query  docuTypeQry  =   element.buildDocuTypeQuery();
        FormStringControl   InventSites        =   element.design().controlName('SalesLine_ManufacturingPlant_CAP');

        SalesLine salesLine    =   SalesLine::find();

        msCtrl   = SysLookupMultiSelectCtrl::construct(element,
                                                InventSites ,
                                               querystr(InventSiteQuery_CAP),
                                                false,
                                                [tableNum(InventSite), fieldNum(InventSite,SiteID)]);
        msCtrl.refreshQuery(docuTypeQry);
        msCtrl.set(element.getSelectedCodes(SalesLine.ManufacturingPlant_CAP));
    }

    [FormControlEventHandler(formControlStr(SalesTable, SalesLine_ManufacturingPlant_CAP), FormControlEventType::Modified)]
    public static void SalesLine_ManufacturingPlant_CAP_OnModified(FormControl sender, FormControlEventArgs e)
    {
        FormRun element = sender.formRun();
        FormControl    purposeCtrl     = element.design().controlName(formControlStr(SalesTable, SalesLine_ManufacturingPlant_CAP));
        FormDataSource salesline_ds    = element.dataSource(formDataSourceStr(SalesTable, SalesLine));
        SalesLine      salesLine       = salesline_ds.cursor();
        SalesLine.ManufacturingPlant_CAP     =   con2Str(msCtrl.getSelectedFieldValues(), ';');
         SalesLine_ds.refresh();
         SalesLine_ds.research(true);
         
    }

}

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.

I have the same question (0)
  • Verified answer
    huijij Profile Picture
    19,811 on at

    Hi HARISH,

    There are no pictures attached to your post, please provide more details to us.

  • Verified answer
    Vignesh.A Profile Picture
    203 on at

    Hi Haresh,

    Please refer the below blog which has the solution for a similar scenario

    https://dax365.blogspot.com/2023/03/multi-select-lookup-in-d365-fo.html

  • HARISH MEHRA Profile Picture
    113 on at

    Thanks Vignesh !!

  • HARISH MEHRA Profile Picture
    113 on at

    Its working Fine. Thanks !!!

  • HARISH MEHRA Profile Picture
    113 on at

    Hi Judy,

    https://dax365.blogspot.com/2023/03/multi-select-lookup-in-d365-fo.html

    This post solved my query . 
    My Multiselect is working fine now.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 577 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 309

#3
Diego Mancassola Profile Picture

Diego Mancassola 259

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans