Hello,
I add multi selected lookup to a field in datasource ,
when Iopen form and I create new record , i get the lookup, I chose values
But the problem is when I add second record , I get the same values selected as the first in lookup
[Form] public class ShippingModeTable extends FormRun { SysLookupMultiSelectCtrl msCtrl; public Query buildDlvModeQuery() { Query dlvModeQry = new Query(queryStr(ShippingModeLookup)); return dlvModeQry; } container getSelectedCodes(str _codeStr) { DlvMode dlvMode; container tmpValues, conIds, conName; int idx; if(_codeStr) { tmpValues = str2con(_codeStr, ';'); } for(idx=1; idx<=conLen(tmpValues); idx ) { dlvMode = DlvMode::find(conPeek(tmpValues, idx)); conIds = dlvMode.RecId; conName = dlvMode.Code; } return [conIds, conName, conIds]; } [DataSource] class ShippingModeTable { [DataField] class ShippingMode { ////// /// public void modified() { ShippingModeTable shippingModeTable = ShippingModeTable_ds.cursor(); shippingModeTable.ShippingMode = con2Str(msCtrl.getSelectedFieldValues(), ';'); ShippingModeTable_ds.refresh(); ShippingModeTable_ds.research(true); } public void lookup(FormControl _formControl, str _filterStr) { //super(_formControl, _filterStr); Query dlvModeQry = element.buildDlvModeQuery(); FormStringControl shippingMode = element.design().controlName('ShippingModeTable_ShippingMode'); EOLEShippingModeTable shippingModeTable = ShippingModeTable_ds.cursor(); msCtrl = SysLookupMultiSelectCtrl::construct(element, shippingMode, querystr(ShippingModeLookup), false, [tableNum(DlvMode), fieldNum(DlvMode,Code)]); msCtrl.set(element.getSelectedCodes(shippingModeTable.ShippingMode)); ShippingModeTable_ds.refresh(); ShippingModeTable_ds.research(true); } } } }
hello HARISH MEHRA
sorry for the late response ,
Yes, I found a solution
[Form] public class ShippingModeTable extends FormRun { SysLookupMultiSelectCtrl msCtrl; ShippingModeTable shippingModeTable; ////// get the mode od delivery from dlvMode Table /// /// /// container of selected element in lookup container getSelectedCodes(str _codeStr) { DlvMode dlvMode; container tmpValues, conIds, conName; int idx; if(_codeStr) { tmpValues = str2con(_codeStr, ';'); } for(idx=1; idx<=conLen(tmpValues); idx ) { dlvMode = DlvMode::find(conPeek(tmpValues, idx)); conIds = dlvMode.RecId; conName = dlvMode.Code; } return [conIds, conName, conIds]; } public void init() { super(); msCtrl = SysLookupMultiSelectCtrl::construct(element, ShippingModeTable_ShippingMode, querystr(ShippingModeLookup)); } [DataSource] class ShippingModeTable { //////update lookup's values /// /// public int active() { int ret; ret = super(); shippingModeTable = ShippingModeTable_ds.cursor(); msCtrl.set(element.getSelectedCodes(shippingModeTable.ShippingMode)); return ret; } [DataField] class ShippingMode { ////// update values in ShippingModeTable /// public void modified() { shippingModeTable.ShippingMode = con2Str(msCtrl.getSelectedFieldValues(), ';'); } } } }
Hello BASMA did you get the answer. Because I am also facing the same issue.
Help will be appreciated.
hello,
Andre Arnaud de Calavon , no I have 3 fields in table , I store the selection in a string field
then this is all the code that I add it .
Mohit Rampal , I see this code and I use it , the problme with this code is how to set the eventHandler npt static
Hi Basma,
Is the coding you shared all the coding related to this lookup? Have you implemented coding to update the selected values on the active() method of the data source?
Do you only have Shipping mode field on this table (where you store the selection in a string field) or also an additional table to store the relations between this table and the Mode of delivery?
André Arnaud de Cal...
292,111
Super User 2025 Season 1
Martin Dráb
230,934
Most Valuable Professional
nmaenpaa
101,156