Advertisements

Filter Pages for Filtering Tables using FILTERPAGEBUILDER

In C/AL code, you can use the FILTERPAGEBUILDER data type to create a filter page that enables users to set filters on multiple tables. Filter pages contains one or more filter controls, where each filter control can be used to set filters on a specific table. In the Microsoft Dynamics NAV client, filter pages are generated at runtime and run in a modal dialog box.

For demo purpose I have created a List page on Item Table. I have added below Variables and Code on Page.
filterpagebuiler-1
When I Run the Page, First Request page is popup to accept filters. Then my Item List Page is opened applying the filter I provided on the Request Page.
filterpagebuiler-2
FILTERPAGEBUILER Data Type Functions

ADDTABLE Function

Adds a filter control for a table to a filter page.

ADDRECORD Function

Adds a filter control for a table to a filter page as specified by a record data type variable.

ADDRECORDREF Function

Adds filter control for a table to a filter page as specified by a recordref variable.

ADDFIELD Function

Adds a table field to the filter control for a table on filter page.

ADDFIELDNO Function

Adds a table field to the filter control for a table as specified by the field number.

GETVIEW function (FilterPageBuilder)

Gets the filter view (which defines the sort order, key, and filters) for the record in the specified filter control of a filter page.

SETVIEW Function

Sets the current filter view, which defines the sort order, key, and filters, for a record in a filter control on a filter page.

RUNMODAL Function (FilterPageBuilder)

Builds and runs the filter page.

COUNT Function (FilterPageBuilder)

Gets the number of filter controls that are specified in the FilterPageBuilder object instance.

NAME Function (FilterPageBuilder)

Gets the name of a table filter control that is included on a filter page based on an index number that is assigned to the filter control.

Advertisements

Filtering on Dimension Values

Microsoft Dynamics NAV supports unlimited dimensions and unlimited dimension values. You can create as many as you want, and you can use those all across the application.

However two of these dimensions have got special treatment by setting them up them as global dimensions.

Why special? Answer could be because the global dimensions values are stored directly on the records they belong to. All other dimension values are stored in a separate table.

This means that you can filter on these two dimensions. In many places in the standard application, these Global Dimension are used on Filter fields that can be used to filter FlowFields.

However, to get any data on any of the other dimensions, you would have to rely on Analysis Views to retrieve the information.

In Microsoft Dynamics NAV 2013 onwards version, the dimensions functionality has been heavily redesigned.

Instead of storing all individual dimension values for each record in separate tables, each unique combination of dimensions and values gets an ID, and this dimension set ID is stored directly on the record that those values belong to.

With this change, all information about dimensions and their values are directly stored on the record.

Since all the required information is stored on the record, though somewhat indirectly, it will now be possible to filter on any dimension and any dimension value. As it turns out, it is, and it’s not that hard to do.

As mentioned, the records contain dimension set IDs, which are integers that represent the combination of dimension values for a specific record. The biggest problem is to convert a typical filter on a dimension into a filter of dimension set IDs.

Fortunately, we already have a few functions in Microsoft Dynamics NAV that can provide that information. With these functions in mind, we can build a logic where you can input any combination of dimensions and dimension values in the form of filters, and you can then calculate the corresponding set of dimension set IDs. With all of these IDs, we can build one long filter string and use it to filter on the dimension set ID field. This enables, with relative ease, direct filtering on Dimension Values.

In Codeunit 408 – DimensionManagement we have functions which can help us getting our task done:

  • GetDimSetIDsForFilter

DimFilter-1

  • GetNextDimSetFilterChunk

DimFilter-2

In Codeunit 46 – SelectionFilterManagement we have functions which can help us getting our task done:

  • GetSelectionFilterForDimensionValue

DimFilter-3

Using these functions we can build our logic to retrieve the required records from tables filtering on Dim Set ID field.

Let’s see the pseudocode of logic to get our work done.

This logic applies to Dimension table. With all values for which filter need to be applied.
DimFilter-4

Before executing above piece of code we have to prepare a Dimension Value record with [Dimension Code + Code (filter)] values with all the required filters we wish to apply filter for.

We can also find out which records do not have a value for one or more dimensions, for this we will add [Dimension Code] but for [Code] we will not provide the value/filter or blank.

Make sure when you define variables of Dimension & Dimension Value don’t forget to set Temporary property to Yes.

Important

Most of the contents you find in this blog will be either inherited from MSDN or Navision Developer IT Pro Help. Some places images are also directly taken from these sites. Purpose is simple to try those stuffs and re-produce adding few things as per my understanding to make easy understanding for others and quick reference.

Here nothing under my own brand or authorship of the content. At any point of time we are just promoting Microsoft stuffs nothing personnel with same.

Hope stuffs used here will not violate any copyright agreement with them. In case by mistake or in-intestinally it happens and the Microsoft feels these should not be used Microsoft have full right to inform me about same and will be glad to take down any such content which may be violating the norms.

Purpose is to promote Navision and share with community.

FB Profile

Like FB Page

%d bloggers like this: