sort lookup

Hi guys,

Need your help again… Thanks in advance…

I have a dropdown on one of the colums on my form’s grid, and I need to sort the values inside that dropdown (sort startingDate, desc), so I made up a lookup, but it never sorts on lines that already has records, but functions very well on new records, there’s no problem also with the ranges…any ideas?

static client void my_Lookup(FormStringcontrol _ctrl)
{
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(myTable), _ctrl);
Query query;
QueryBuildDataSource qbds;

;

sysTableLookup.addLookupfield(fieldnum(myTable,periodId));
sysTableLookup.addLookupfield(fieldnum(myTable,name));
sysTableLookup.addLookupfield(fieldnum(myTable,startingDate));
sysTableLookup.addLookupfield(fieldnum(myTable,endingDate));

query = new Query();

qbds = query.addDataSource(tablenum(myTable));
qbds.clearRanges();
qbds.addSortField(fieldnum(myTable,startingDate),sortOrder::Descending);

qbds.addRange(fieldnum(myTable,endingDate)).value(SysQuery::valueEmptyString());
qbds.addRange(fieldnum(myTable,endingDate)).value(queryRange(today(),0));

sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}

Thanks a lot… :slight_smile:

Hello, try to use

sysTableLookup.parmUseLookupValue(

false);

right before sysTableLookup.performFormLookup();