I have two multi select lookups, where the second one depends on the result of the first one.
But I did not put the "range code" in my first post, because I got an explicit Problem using the "group by".
I try to give you some additional information:
1. My report needs two multi select lookups where the second one depends on the first one.
2. The second lookup get his data from an temporary table (In Memory).
My UI Builder class looks like this:
class LoadedShelfLocationUIBuilder_WEW extends SrsReportDataContractUIBuilder
{
private DialogField dfInventLocationId;
private DialogField dfWEWLocationGroup;
LoadedShelfLocationWMSLocationTmp_WEW tmpWMSLocation;
LoadedShelfLocationContract_WEW contract;
public void postBuild()
{
super();
contract = this.dataContractObject();
tmpWMSLocation.initTable();
// binding dialogs with contract fields
dfInventLocationId = this.bindInfo().getDialogField(this.dataContractObject(), methodStr(LoadedShelfLocationContract_WEW, parmInventLocationId));
dfWEWLocationGroup = this.bindInfo().getDialogField(this.dataContractObject(), methodStr(LoadedShelfLocationContract_WEW, parmWEWLocationGroup));
}
public void postRun()
{
//this.lookupWEWLocationGroupCtrl();
dfInventLocationId.registerOverrideMethod(methodStr(FormStringControl, lookup),
methodStr(LoadedShelfLocationUIBuilder_WEW, lookupInventLocationId),
this);
dfWEWLocationGroup.registerOverrideMethod(methodStr(FormStringControl, lookup),
methodStr(LoadedShelfLocationUIBuilder_WEW, lookupWEWLocationGroup),
this);
if (dfWEWLocationGroup)
{
dfWEWLocationGroup.lookupButton(2);
}
if (dfInventLocationId)
{
dfInventLocationId.lookupButton(2);
}
}
private void lookupInventLocationId(FormStringControl _control)
{
Query query = new Query();
QueryBuildDataSource qbd;
int mutiSelectTableNum = tablenum(WMSLocation);
container selectedFields = [mutiSelectTableNum, fieldname2id(mutiSelectTableNum, fieldstr(WMSLocation, InventLocationId))];
qbd = query.addDataSource(tableNum(WMSLocation));
qbd.addRange(fieldNum(WMSLocation, WEWLocationGroup)).value(SysQuery::valueNotEmptyString());
qbd.addGroupByAndSelectionField(fieldNum(WMSLocation, InventLocationId));
qbd.fields().dynamic(NoYes::No);
qbd.fields().clearFieldList();
qbd.fields().addField(fieldNum(WMSLocation, InventLocationId));
SysLookupMultiSelectGrid::lookup(query, _control, _control, _control, selectedFields);
}
private void lookupWEWLocationGroup(FormStringControl _control)
{
Query query = new Query();
QueryBuildDataSource qbd;
QueryRun queryRun;
int mutiSelectTableNum = tablenum(LoadedShelfLocationWMSLocationTmp_WEW);
container selectedFields = [mutiSelectTableNum, fieldname2id(mutiSelectTableNum, fieldstr(LoadedShelfLocationWMSLocationTmp_WEW, WEWLocationGroup))];
qbd = query.addDataSource(tableNum(LoadedShelfLocationWMSLocationTmp_WEW));
qbd.addGroupByAndSelectionField(fieldNum(LoadedShelfLocationWMSLocationTmp_WEW, WEWLocationGroup));
qbd.fields().dynamic(NoYes::No);
qbd.fields().clearFieldList();
qbd.fields().addField(fieldNum(LoadedShelfLocationWMSLocationTmp_WEW, WEWLocationGroup));
//qbd.addRange(fieldNum(LoadedShelfLocationWMSLocationTmp_WEW, inventLocationId)).value(dfInventLocationId.value());
SysLookupMultiSelectGrid::lookup(query, _control, _control, _control, selectedFields);
}
private void lookupWEWLocationGroupCtrl()
{
Query query = new Query();
QueryBuildDataSource qbd;
QueryRun queryRun;
int mutiSelectTableNum = tablenum(LoadedShelfLocationWMSLocationTmp_WEW);
container selectedFields = [mutiSelectTableNum, fieldname2id(mutiSelectTableNum, fieldstr(LoadedShelfLocationWMSLocationTmp_WEW, WEWLocationGroup))];
//qbd = query.addDataSource(tableNum(LoadedShelfLocationWMSLocationTmp_WEW));
//qbd.addGroupByAndSelectionField(fieldNum(LoadedShelfLocationWMSLocationTmp_WEW, WEWLocationGroup));
//qbd.fields().dynamic(NoYes::No);
//qbd.fields().clearFieldList();
//qbd.fields().addField(fieldNum(LoadedShelfLocationWMSLocationTmp_WEW, WEWLocationGroup));
//qbd.addRange(fieldNum(LoadedShelfLocationWMSLocationTmp_WEW, inventLocationId)).value(dfInventLocationId.value());
queryRun = new QueryRun(queryStr(LoadedShelfLocationWMSLocationTmp_WEW));
queryRun.setCursor(tmpWMSLocation);
SysLookupMultiSelectCtrl::constructWithQueryRun(this.dialog().dialogForm().formRun(), dfWEWLocationGroup.control(), queryRun, false, selectedFields);
}
}
In the "tmpWMSLocation.initTable()" i create the data of the temp table.
I tried different approaches using "SysLookupMultiSelectCtrl" and "SysLookupMultiSelectGrid".
Both of them cause different Problems:
The "SysLookupMultiSelectGrid" doesn't show any data at all (see "lookupWEWLocationGroup(FormStringControl _control)"):

and the "SysLookupMultiSelectCtrl" got the "group by" Problem (see "lookupWEWLocationGroupCtrl()").
As soon as I but the group by in the query, the selected values are not shown anymore in the control. The same problem occurs, when I am trying to write the query by code and change
addSelectionField(fieldNum(LoadedShelfLocationWMSLocationTmp_WEW, WEWLocationGroup)); to -> addGroupByAndSelectionField(fieldNum(LoadedShelfLocationWMSLocationTmp_WEW, WEWLocationGroup));
I am also still missing an "registerOverrideMethod" for "SysLookupMultiSelectCtrl", but there is the Problem, that the "SysLookupMultiSelectCtrl"-Class is also overriding the lookup method.
fsCtrlNames.registerOverrideMethod('lookup', 'ctrlNames_lookup', this);
So i am not even sure if it is possible?
Maybe using the "SysLookupMultiSelectGrid" is the easier way to solve my problem, but i was not able to get it run.
If you need more information, let me know.
Thank you in advance.