Chapter 9. Advanced Features and Frameworks

In this chapter, we will introduce some advanced features and use them to extend our solution. The topics we will cover are as follows:

  • Adding custom filters to list pages
  • Advanced methods of adding query ranges
  • Using the SysOperation framework
  • Using the SysOperation framework's execution modes
  • Customizing the user interface displayed by the SysOperation framework
  • Tracking progress of scheduled tasks
  • Understanding the global address book
  • Accessing the financial dimension framework

Adding custom filters to list pages

Microsoft introduced a change in Dynamics AX 2012's List pages that meant that X++ can no longer be written directly on the form. This was, in part, to help provide a more seamless experience between the web interface (Enterprise Portal) and the Windows client.

One drawback of this is that the old method of using edit methods to add quick filters to a list page could no longer be used, as edit methods must run on the form if they are to access any data source other than the current record's form data source.

Microsoft obviously solved this and provided a new method to add custom filter controls. This, in many ways, is better than the previous method, as it does not require us to write code.

A list page created from the form template is made up of an action pane, a custom filter group control, and a grid.

When we add form controls to the Filters group control, they get three new properties:

  • FilterDataSource
  • FilterField
  • FilterExpression

The first two properties define the field that the filter applies to, and the third property is the filter. The expression %1 means the value the user entered. Setting the FilterField property and leaving FilterExpression at its default value of %1 will simply filter the field by what the user enters.

AX does this in the same way as we construct a QueryBuildRange object against the data source, which means that the user can use wildcards and value ranges. This is fine for simple filters, but sometimes, we need to introduce more intelligence. Again, we can do this as we can treat it as a QueryBuildRange object.

Some examples of useful expressions are as follows:

FilterExpression

Result

%1

Pass the value directly to the resulting QueryBuildRange value

..%1

All values up to the value the user entered

(dayRange(-%1, 0))

Uses SysQueryRangleUtil to filter a date field from a number of days in the past until the current date

(lessThanDate(%1))

Uses SysQueryRangleUtil to filter the field for all records before the date the user entered

You can also be very creative with FilterExpression, but this can become hard to read; keeping it simple is important.

In order to add a simple filter to a list page, follow these steps:

  1. On the ConFMSVehicleTableListPage form, expand Designs | Design.
  2. The Filters form group control will be set as not visible by default. Change the Visible property to Yes.
  3. Right-click on the Filter group control and choose New | StringEdit.
  4. Rename the control to FilterVehicleName and complete the filter properties to filter the field ConFMSVehicleTable.Name. Leave FilterExpression as %1.
  5. Save the form and open it.
  6. Entering a partial match will return no result; you have to place a * sign. We wish to filter on the wildcard by default. Close the form and alter FilterExpression to *%1*.

Entering a partial match now returns all vehicles that contain the string entered.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.157.34