My 2p about ERP Solutions, Information Worker Solutions and other software products (mainly Microsoft Dynamics AX and Microsoft SharePoint).

02 November 2010

Adding a custom filter to a form

by Patrik Luca 0 comments

Tag



Business requirement: Adding a custom filter to a form

In some cases it is required to ease the filtering on a form. In some cases end users don’t have enough Dynamics AX knowledge to use the Advanced Filter Sort functionality to create a query on the form to achive their filtering requirements.

Solution: Add a checkbox custom filter

The solution is elaborated by means of an example. Suppose you want to provide the end user with an easy filtering on the customer form to show only customers with active Projects (Projects not in the Project Stage Completed).

To achive this, you can follow these steps:

  1. Duplicate the CustTable form and add a checkbox control ctrlCustActProjs to it for the filtering purposes. Set the AutoDeclaration property of the checkbox to Yes.
  2. Add the ProjTable data source to the form and link it to the CustTable data source.
  3. Override the executeQuery method of the CustTable data source as follows:
    public void executeQuery()
    {
    QueryBuildDataSource qbdsProjTable =
    this.query().dataSourceTable(tableNum(ProjTable));
    QueryBuildRange qbrProjStatus;
    ;

    if (ctrlCustActProjs.value() == NoYes::Yes)
    {
    qbdsProjTable.enabled(true);
    qbrProjStatus =
    SysQuery::findOrCreateRange(qbdsProjTable,
    fieldnum(ProjTable, Status));
    qbrProjStatus.value(
    Global::queryNotValue(
    ProjStatus::Completed));
    }
    else
    {
    qbdsProjTable.enabled(false);
    }
    super();
    }




By toggling the checkbox only customers with active Projects will be shown or not.

Enabling the qbdsProjTable QueryBuildDataSource based on the checkbox links or removes the ProjTable to the CustTable in the form query.

The search for only active Projects is achieved by adding or finding the qbrProjStatus QueryBuildRange. Use the Global::queryNotValue to look up values different from a base Enum value.


Comments 0 comments

Patrik Luca, Ieper, BELGIUM
Feel free to use or spread all of the content on my blog. In return, linking back to my blog would be greatly appreciated. All my posts and articles are provided "AS IS" with no warranties.

Subscribe feeds via e-mail
Subscribe in your preferred RSS reader

Subscribe feeds rss Most Read Entries

Subscribe feeds rss Recent Entries

Categories

Recommended Books


Subscribe feeds rss Recent Comments

This Blog is part of the U Comment I Follow movement in blogosphere. Means the comment field of this blog is made DOFOLLOW. Spam wont be tolerated.

Live Traffic Feed

Recent Visitors

Blog Archive

My Blog List

Followers

Guest Links