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(),';'); } }
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.
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.
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);
André Arnaud de Cal...
291,965
Super User 2025 Season 1
Martin Dráb
230,817
Most Valuable Professional
nmaenpaa
101,156