Filter Form Look:
Modified Method:
public boolean modified()
{
boolean ret;
ret = super();
PurchTable_DS.executeQuery();
return ret;
}
Lookup Method:
public void lookup()
{
Query query = new Query();
super();
SysTableLookup SysTableLookup = SysTableLookup::newParameters(tableNum(TableName),this);
QueryBuildDataSource qbds = query.addDataSource(tableNum(TableName));
SysTableLookup.addLookupfield(fieldNum(TableName,Field1));
SysTableLookup.addLookupfield(fieldNum(TableName,Field2));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
Execute Query Method:
public void executeQuery()
{
PurchTable_DS.query().dataSourceName('PurchTable').clearRanges();
PurchTable_DS.init();
if(VendAccount.valueStr())
{
str account = VendAccount.valueStr();
if(account != '0')
this.query().dataSourceTable(tableNum(PurchTable)).addRange(fieldNum(PurchTable, OrderAccount)).value(account);
}
if(PurchType.valueStr())
{
this.query().dataSourceTable(tableNum(PurchTable)).addRange(fieldNum(PurchTable, PurchStatus)).value(PurchType.valueStr());
}
if(InventSiteId.valueStr())
{
str site = InventSiteId.valueStr();
this.query().dataSourceTable(tableNum(PurchTable)).addRange(fieldNum(PurchTable,InventSiteId)).value(site);
}
if (monthfilter.valueStr())
{
TransDate lastDate = endMth(monthfilter.dateValue());
TransDate startDate = dateStartMth(monthfilter.dateValue());
this.query().dataSourceTable(tablenum(PurchTable)).addRange(fieldnum(PurchTable, DeliveryDate)).value(sysQuery::range(startDate, lastDate));
}
if (!monthfilter.valueStr())
{
TransDate lastDate ;
TransDate startDate;
if(dayOfMth(today()) <16)
{
lastDate = mkDate(15,mthOfYr(today()),Year(today()));
startDate = mkDate(16,mthOfYr(today())-1,Year(today()));
}
if(dayOfMth(today()) >15)
{
lastDate = mkDate(15,mthOfYr(today())+1,Year(today()));
startDate = mkDate(16,mthOfYr(today()),Year(today()));
}
this.query().dataSourceTable(tablenum(PurchTable)).addRange(fieldnum(PurchTable, DeliveryDate)).value(sysQuery::range(startDate, lastDate));
} this.query().dataSourceTable(tableNum(PurchTable)).addSortField(fieldNum(PurchTable,DeliveryDate),SortOrder::Descending);
super();
}
/// Enjoy 👍