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, ...
Suggested Answer

How to refresh multi selected lookup in SalesTable form.

(0) ShareShare
ReportReport
Posted on by 113

Hi Experts, 

I  add multi selected lookup to a field in SalesLine Table ,

when I open SalesTable form and I create new record , I get the lookup, I choose values .

But the problem is when I add second record , I get the same values selected as the first in lookup.

[Extensionof(formstr(SalesTable))]
public final class LookupValueClass_CAP_Extension
{
    public  SysLookupMultiSelectCtrl msCtrlCust;
    public void init()
    {

        FormStringControl SaleLine_ManufacturingPlant_CAP;
        next init();
        SaleLine_ManufacturingPlant_CAP = this.design().controlname(formControlStr(SalesTable,SalesLine_ManufacturingPlant_CAP));

        msCtrlCust = SysLookupMultiSelectCtrl::construct(this,
                                                SalesLine_ManufacturingPlant_CAP ,
                                               querystr(InventSiteQuery_CAP),
                                                false,
                                                [tableNum(InventSite), fieldNum(InventSite,SiteId)]);
      
        this.parmMultiselectCtl(msCtrlCust);
  
    }

        public SysLookupMultiSelectCtrl parmMultiselectCtl(SysLookupMultiSelectCtrl _msCtrlCust = msCtrlCust)
        {
        msCtrlCust = _msCtrlCust;
        return msCtrlCust;
        }




//public class MultiSelectEH

//{
    
    [FormDataFieldEventHandler(formDataFieldStr(SalesTable, SalesLine, ManufacturingPlant_CAP), FormDataFieldEventType::Modified)]
    public static void ManufacturingPlant_CAP_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
    {
        FormRun formRun = sender.datasource().formRun();
        SysLookupMultiSelectCtrl msCtrlCust = formRun.parmMultiselectctl();

        SalesLine salesLine = FormRun.dataSource(formDataSourceStr(SalesTable,SalesLine)).cursor() as SalesLine ;
        salesLine.ManufacturingPlant_CAP = con2Str(msCtrlCust.getSelectedFieldValues(),';');

          }
    



}

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

    Hi HARISH,

    Based on your information, it is not difficult to surmise that you should have a problem with line 42 of the code. It is recommended that you debug to determine the values of the individual variables, preferably using the + to splice the strings. Like something as:

    salesLine.ManufacturingPlant_CAP = salesLine.ManufacturingPlant_CAP + SysOperationHelper::convertMultiSelectedValueString(selectedStr);

  • HARISH MEHRA Profile Picture
    113 on at

    Hi Judy,

    Thanks for the reply.

    My main problem is suppose when I go In Line No. -1(SalesLine) . I selected the value from the multi lookup. Now when I move to LineNo.-2 and open the lookup .The same values already coming selected which I selected in Line 1.

  • Vignesh.A Profile Picture
    203 on at

    Hi Haresh,

    The code you have written on "init" method will hold the object created untill the form is closed. But in your case, you require this for sales line. Since multiple records can be there in sales line, we need to initialize the object for "msCtrlCust" for each record.

    Can you try moving the code written on "init" method to Sales Line Datasource "active" method so that the object will be created for each lines respectively.

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 649

#2
André Arnaud de Calavon Profile Picture

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

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 242 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans