I created a lookup using SysLookupMultiSelectCtrl and it's working fine but there is one case that has a problem:
When the Value field is empty and I choose some values and click select.. it's not reflected on the field and it's still empty.
but when the Value field already has a value and I modify it, the lookup selected values are reflected on the field text.(the 2nd picture)
Here's the code I use to handle this scenario:
[Form]
public class SetupForm extends FormRun
{
SysLookupMultiSelectCtrl msCtrl;
str prevLookupValue = '';
private str getLookupValue()
{
return con2Str(msCtrl.getSelectedFieldValues(),',');
}
public void init()
{
Query q;
FormStringControl frmStringControl;
FormRun frmRun;
super();
q = UtilityClass::getEmptyLookupQuery();
frmStringControl = element.design().controlName(formControlStr(SetupForm,Grid_Value));
frmRun = frmStringControl.formRun();
msCtrl = SysLookupMultiSelectCtrl::constructWithQuery(frmRun,frmStringControl,q);
}
private void getLookupQuey()
{
Query q;
FormStringControl frmStringControl = element.design().controlName(formControlStr(SetupForm,Grid_Value));
FormRun frmRun = frmStringControl.formRun();
SetupTable setupTable = SetupTable_ds.cursor();
If(setupTable.Field)
{
If(setupTable.Field == 'AccountNum')
{
if(setupTable.TableOption == TableOption::VendTable)
q = UtilityClass::getVendorLookupQuery();
else
q = UtilityClass::getCustomerLookupQuery();
}
else If(setupTable.Field == 'CustAccount')
q = UtilityClass::getCustomerLookupQuery();
else If(setupTable.Field == 'CustGroup')
q = UtilityClass::getCustGroupLookupQuery();
else If(setupTable.Field == 'VendGroup')
q = UtilityClass::getVendGroupLookupQuery();
else
q = UtilityClass::getEmptyLookupQuery();
}
msCtrl.refreshQuery(q);
}
[DataSource]
class SetupTable
{
public void selectionChanged()
{
super();
element.getLookupQuey();
}
[DataField]
class Field
{
public void modified()
{
super();
element.getLookupQuey();
}
}
[DataField]
class Value
{
public void modified()
{
if(element.getLookupValue() != element.prevLookupValue)
DYNADDVTable.Value = element.getLookupValue();
element.prevLookupValue = element.getLookupValue();
super();
}
}
}
}