How to: Filter Records in a Form
Good day Everyone,
Today I will show you how to create a query range in a form data source to filter records.
On my scenario, I have to create a form that shows basic SO informations like SalesId, Customer Account and Status and creation date. But I can’t show any SO with status Invoiced.
On my scenario, I have to create a form that shows basic SO informations like SalesId, Customer Account and Status and creation date. But I can’t show any SO with status Invoiced.
First, I have created a new form using SalesTable as data source and then I created a Grid to display information. It looks like this:
The next step is very simple. Many query operations can be executed using the method query() of the form data source. This is done in the executeQuery() method on the form’s data source.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| public void executeQuery() { QueryBuildRange salesStatusQBR; ; // Creating a query range for the field Sales Status. salesStatusQBR = this .query().dataSourceTable(tableNum(SalesTable)) .addRange(fieldNum(SalesTable, SalesStatus)); // Assigning the value "!Invoiced" to show all SO NOT invoiced. salesStatusQBR.value(strFmt( '!%1' , SalesStatus::Invoiced)); // Hiding query value from end user. salesStatusQBR.status(2); super(); } |
In the code above I have created a new Range to filter the field SalesStatus from SalesTable and then I have assigned the value “!Invoiced” to show everything that does not containInvoiced as status.
As a bonus, I have shown how to hide it from user.
As a bonus, I have shown how to hide it from user.
No comments:
Post a Comment