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 117

[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.

  • Verified answer
    huijij Profile Picture
    19,813 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
    117 on at

    Thanks Vignesh !!

  • HARISH MEHRA Profile Picture
    117 on at

    Its working Fine. Thanks !!!

  • HARISH MEHRA Profile Picture
    117 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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

#1
André Arnaud de Calavon Profile Picture

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

#2
Aayush Tiwari Profile Picture

Aayush Tiwari 217

#3
Subra Profile Picture

Subra 200 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans