Quantcast
Viewing all articles
Browse latest Browse all 17314

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.

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:

Image may be NSFW.
Clik here to view.
2014-09-15 19_05_10-Project _QueryRangeOnForm

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.

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 contain Invoiced as status.
As a bonus, I have shown how to hide it from user.

This is the result:
Image may be NSFW.
Clik here to view.

For more information about query range expressions, I recommend to read Using Expressions in Query Ranges [AX 2012] from MSDN.


Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 17314

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>