Saturday, May 19, 2012

How to select Distinct Using X++?

public void lookup(FormControl _formControl, str _filterStr)

{

SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(MBSR_ACC_PATIENTS), _formControl);

Query query = new Query();

QueryBuildDataSource queryBuildDataSource;

;

sysTableLookup.addLookupfield(fieldnum(MBSR_ACC_PATIENTS, ACCOUNT_NO));

sysTableLookup.addLookupfield(fieldnum(MBSR_ACC_PATIENTS, ACCOUNT_NM));

queryBuildDataSource = query.addDataSource(tablenum(MBSR_ACC_PATIENTS));

queryBuildDataSource.addSortField(fieldnum(MBSR_ACC_PATIENTS, ACCOUNT_NO));

queryBuildDataSource.addSortField(fieldnum(MBSR_ACC_PATIENTS, ACCOUNT_NM));

queryBuildDataSource.orderMode(ordermode::GroupBy);

sysTableLookup.parmQuery(query);

sysTableLookup.performFormLookup();



super(_formControl, _filterStr);

}