Group By on a Look-Up Query

Whenever we try to use a group by on a lookup, the group by used to come for the first time, and later it never showed.
investigations revealed that it second time it fired a Order By Asc instead of group by query. this problem was fixed by passing parameter false to

sysTableLookup.parmUseLookupValue(false);

Sample

void orderNoLookup(FormControl _control) { SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(InventTrans),_control); QueryBuildDataSource inventTransQbds; Query query;// = element.initQuery(); ;

sysTableLookup.addLookupfield(fieldnum(InventTrans, TransRefId),
                              true);
inventTransQbds = query.dataSourceNo(1);

inventTransQbds.addSortField(fieldnum(InventTrans,TransRefId));

inventTransQbds.orderMode(OrderMode::GroupBy);

sysTableLookup.parmUseLookupValue(false);
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();

}

This article is part of the GWB Archives. Original Author: Shekhar

New on Geeks with Blogs