Hi,
This post will show you yo filter the values as per user selection in the form.
Assume a form has two controls such as,
1."sales status" - this will filter as per status of Sales Order.
2."creator" - this will filter Sales Order as per the current user.
Below code will get the value from the form control and filter as such:
public void executeQuery()
{
;
SalesTable_ds.query().dataSourceTable(tableNum(SalesTable)).clearRanges();
if(statusFilter.valueStr() == enum2str(SalesStatus::Backorder))
{ SalesTable_ds.query().dataSourceTable(tableNum(SalesTable)).addRange(fieldnum(SalesTable,SalesStatus)).value(sysquery::value(SalesStatus::Backorder));
}
else if(statusFilter.valueStr() == enum2str(SalesStatus::Delivered))
{ SalesTable_ds.query().dataSourceTable(tableNum(SalesTable)).addRange(fieldnum(SalesTable,SalesStatus)).value(sysquery::value(SalesStatus::Delivered));
}
else if(statusFilter.valueStr() == enum2str(SalesStatus::Invoiced))
{
SalesTable_ds.query().dataSourceTable(tableNum(SalesTable)).addRange(fieldnum(SalesTable,SalesStatus)).value(sysquery::value(SalesStatus::Invoiced));
}
if(CreatorFilter.value() == true)
{
SalesTable_ds.query().dataSourceTable(tableNum(SalesTable)).addRange(fieldnum(SalesTable,CreatedBy)).value(sysquery::value(curUserId()));
}
super();
}