Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

How to refresh multi selected lookup in SalesTable form.

(0) ShareShare
ReportReport
Posted on by 100

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(),';');

          }
    



}

  • Vignesh.A Profile Picture
    Vignesh.A 203 on at
    RE: How to refresh multi selected lookup in SalesTable form.

    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.

  • HARISH MEHRA Profile Picture
    HARISH MEHRA 100 on at
    RE: How to refresh multi selected lookup in SalesTable form.

    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.

  • Suggested answer
    huijij Profile Picture
    huijij 19,811 on at
    RE: How to refresh multi selected lookup in SalesTable form.

    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);

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,817 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans