1 SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(QVS_PriceDiscVendName), _lookupCtrl);
2 Query QE;
3 QueryBuildDataSource DS;
4 ;
5
6 QE = new Query();
7 DS = QE.addDataSource(tablenum(QVS_PriceDiscVendName));
8 DS.addRange(fieldnum(QVS_PriceDiscVendName,ItemRelation)).value(SysQuery::value(_itemId));
9 DS.addGroupByField(fieldnum(QVS_PriceDiscVendName, AccountRelation));
10 DS.addSelectionField(fieldnum(QVS_PriceDiscVendName, AccountRelation), SelectionField::Database);
11 DS.addGroupByField(fieldnum(QVS_PriceDiscVendName, NameAlias));
12 DS.addSelectionField(fieldnum(QVS_PriceDiscVendName, NameAlias), SelectionField::Database);
13 DS.orderMode(OrderMode::GroupBy);
14
15 sysTableLookup.addLookupfield(fieldnum(QVS_PriceDiscVendName, AccountRelation));
16 sysTableLookup.addLookupfield(fieldnum(QVS_PriceDiscVendName, NameAlias));
17
18 sysTableLookup.parmQuery(QE);
19 sysTableLookup.parmUseLookupValue(false); //While use group by in the lookup, this parm is very important.
20 sysTableLookup.performFormLookup();