Hi,
I want to create a lookup with the product master that has a variant.
So i created a query with a innerjoin relation. It worked well until I added a group by to remove the duplicated product number.
When i added the group by the lookup is empty.
The problem seems to be the combination of relation and group by. Because the lookup is filled with the relation without the group by,
and it is also filled with the group by withouthe relation.
Can someone help me ?
Here is my code :
public void lookup()
{
SysTableLookup sysTableLookup;
QueryBuildDataSource qbEcoREsProduct;
Query query = new Query();
sysTableLookup =
SysTableLookup::newParameters(tableNum(EcoREsProductMaster), this);
qbEcoREsProduct = query.addDataSource(tableNum(EcoREsProductMaster));
qbEcoREsProduct = qbEcoREsProduct.addDataSource(tableNum(EcoResDistinctProductVariant));
qbEcoREsProduct.joinMode(JoinMode::InnerJoin);
qbEcoREsProduct.relations(false);
qbEcoREsProduct.addLink(fieldNum(EcoREsProductMaster, RecId),
fieldNum(EcoResDistinctProductVariant, ProductMaster));
//Group by section
qbEcoREsProduct.addGroupByField(fieldnum(EcoREsProductMaster, DisplayProductNumber));
qbEcoREsProduct.addSortField(fieldnum(EcoREsProductMaster, DisplayProductNumber));
qbEcoREsProduct.orderMode(OrderMode::GroupBy);
sysTableLookup.addLookupfield(fieldNum(EcoREsProductMaster, DisplayProductNumber));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}