[Extensionof(formstr(SalesTable))] final class SalesLine_CAP_Extension { [FormControlEventHandler(formControlStr(SalesTable, SalesLine_ManufacturingPlant_CAP), FormControlEventType::Lookup)] public static void SalesLine_ManufacturingPlant_CAP_OnLookup(FormControl sender, FormControlEventArgs e) { Args args; FormRun formRun; MultiSelectionHelper Msh; InventSite inventSite; FormDataSource salesLine_ds = sender.formRun().dataSource(formDataSourceStr(SalesTable, SalesLine)); SalesLine salesLine = salesLine_ds.cursor(); str store; int i, conLength; int64 recId; SysLookupMultiSelectValues delimitedControlValues; container controlValues; container selectField; FormStringControl d = sender.formRun().design().controlname(formControlStr(SalesTable, SalesLine_ManufacturingPlant_CAP)); FormDataSource inventSite_ds; FormControlCancelableSuperEventArgs event = e as FormControlCancelableSuperEventArgs; //Add the categorymultiselectlookupfilter as an argument for lookup args = new args(formStr(InventSite)); //Add the current conrol (Grid Column) as lookup caller args.caller(d); formRun = classFactory.formRunClass(args); //Initialize and perform lookup form formRun.init(); d.performFormLookup(formRun); inventSite_ds = formRun.dataSource(); delimitedControlValues = d.text(); if(delimitedControlValues) { controlValues = str2con(delimitedControlValues, ';', false); conLength = conlen(controlValues); for (i = 1; i <= conLength; i ) { inventSite_ds.findRecord(InventSite::find(conpeek(controlValues, i))); inventSite_ds.mark(true); } } formRun.wait(); if(formRun.closedOk()) { Msh = MultiSelectionHelper::construct(); Msh.parmDatasource(inventSite_ds); for (InventSite = inventSite_ds.getFirst(true) ? inventSite_ds.getFirst(true) : inventSite_ds.cursor();inventSite; InventSite = inventSite_ds.getNext()) { store = InventSite.SiteId ";"; } d.text(store); SalesLine.ManufacturingPlant_CAP = d.valueStr(); SalesLine.write(); // SalesLine.reread(); // SalesLine.refresh(); } event.CancelSuperCall(); } }Hi,
Can Anyone Suggest.
Thanks Vignesh. It worked.
Hi Harish,
We need to tweak the code little bit to get this achieved.
Below is the sample code similar to your scenario.
1. Create an extension class for the for the sales table form
2. make CoC for the form init method
3. Create a parm method to hold the multilookupSelectCtrl object
4. Create an Event Handler class to take the onLookup Event of the form control where the multi select lookup is required.
5. Write the below code to set the selected value to the field.
Below is the result of the code.
Thanks for the reply Vignesh.
I have also used 'SysLookupMultiSelectCtrl' But the result is same. When I am selecting multi records it is showing like - 0;0 (Zero for each record selected).
Hi Harish,
From your code, I understand that, you are opening the Invent site form through arguments during the lookup method and and try to select multiple records in it.
But we can have a simple approach to it. Try to use "SysLookupMultiSelectCtrl" class to bring a lookup with multilple record selection options.
There are many standard forms which uses this class to bring multi select lookup. You can find reference of this class to see how there are being used.
André Arnaud de Cal...
292,074
Super User 2025 Season 1
Martin Dráb
230,900
Most Valuable Professional
nmaenpaa
101,156