I need to add in my DialogField a MultiSelect Lookup. The values show aren't from record table (like Custom Account...), but they come from a BaseEnum.
I want to select more than one value from lookup:
For example, the user can choose at the same time Planned and Pais. My current code is this:
My class extends RunBaseBatch
, in
public Object dialog()
{
DialogRunbase dialog = super();
;
dlgMultiSelect= dialog.addFieldValue(enumStr(SubledgerJournalEntryType),"","Select MULTIPLE VALUES","Select MULTIPLE VALUES");
return dialog;
}
How can allow Multi Select lookup?
If it can not possible, there is other way for multiple lookup?
Thanks in advance
Feel free to use this test class for inspiration:
class StackOverflowTestDialog extends RunBase
{
DialogRunbase dlg;
FormBuildStringControl formBuildCtrl;
SysLookupMultiSelectCtrl sysLookupMultiSelectCtrl;
}
static void main(Args _args)
{
StackOverflowTestDialog testDialog = new StackOverflowTestDialog();
if (testDialog.prompt())
{
testDialog.run();
}
}
public Object dialog()
{
DialogGroup dlgGrp;
FormBuildControl grpCtrl;
dlg = super();
dlgGrp = dlg.addGroup();
grpCtrl = dlg.formBuildDesign().control(dlgGrp.formBuildGroup().id());
formBuildCtrl = grpCtrl.addControl(FormControlType::String, identifierstr(ctrlTypes));
formBuildCtrl.label("@SYS329959");
return dlg;
}
public void dialogPostRun(DialogRunbase _dialog)
{
CFMEnumLookupTmp lookupTmp;
FormRun formRun;
Query q;
QueryRun qr;
QueryBuildDataSource qbds;
DictEnum dictEnum;
int i;
super(dlg);
formRun = _dialog.dialogForm().formRun();
if (formRun)
{
//Fill in temporary table with enum values
dictEnum = new DictEnum(enumNum(SubledgerJournalEntryType));
for (i = 0; i < dictEnum.values(); i++)
{
lookupTmp.EnumValueLabelText = dictEnum.index2Label(i);
lookupTmp.insert();
}
//Prepare a queryRun to work with the temporary table
q = new Query();
qbds = q.addDataSource(tableNum(CFMEnumLookupTmp));
qbds.addSelectionField(fieldNum(CFMEnumLookupTmp, EnumValueLabelText));
qr = new QueryRun(q);
qr.setCursor(lookupTmp);
//Multi-select control framework class
sysLookupMultiSelectCtrl = SysLookupMultiSelectCtrl::constructWithQueryRun(
formRun,
formRun.design().control(formBuildCtrl.id()),
qr,
true,
[tableNum(CFMEnumLookupTmp), fieldNum(CFMEnumLookupTmp, EnumValueLabelText)]
);
}
}
public boolean getFromDialog()
{
if (sysLookupMultiSelectCtrl)
{
info('Result: ' + con2Str(sysLookupMultiSelectCtrl.getSelectedFieldValues()));
}
return true;
}