Definition, Use and Example of FILTERGROUP

AndwianAndwian Member Posts: 627
Dear Experts,

I have read the NAV online help of the definition of the FILTERGROUP, however I still unable to understand what is it for.
FILTERGROUP (Record)
Use this function to change the filter group that is being applied to the table. You can also use this function to return the number of the current filtergroup. You cannot return the number of the filtergroup and set a new filtergroup at the same time.

A filtergroup can contain a filter for a Record that has been set earlier with SETFILTER or SETRANGE. The total filter applied is the combination of all the filters set in all the filtergroups.

[CurrGroup] := Record.FILTERGROUP([NewGroup])
CurrGroup

Data type: integer

The number of the current filter group.

Record

Data type: record

A record pointing to the table you want to work with.

NewGroup

Data type: integer

The number of the filter group you want to use.

Settings
There are filtergroups with numbers from 0 to 255.

Comments
When you select a FILTERGROUP, subsequent filter settings - by SETFILTER or SETRANGE - apply to that group.

All groups are active at all times. The only way to disable a group is to remove the filters set in that group.

Filters in different groups are all effective simultaneously; that is: if in one group, a filter is set on customer numbers 1000..2000, while in another group, a filter is set on customer numbers 1800..3000, the result will be that only numbers in the range 1800..2000 are visible.

C/SIDE uses 7 FILTERGROUPS internally:

Number
Name
Description

0 Std The default group where filters are placed when no other group has been selected explicitly. This group is used for filters that can be set from the filter dialogs by the end user.
This group is also used for the filtering action that is the result of the RunFormLink property on a form.

1 Global Not used, but may be used in the future.
2 Form Used for the filtering actions that result from the SETTABLEVIEW function; from the SourceTableView property; and from the DataItemTableView property.
3 Exec Used for the filtering actions that result from the SubFormView and RunFormView properties.
4 Link Used for the filtering actions that result from the DataItemLink and SubFormLink properties.
5
Temp
Not used, but may be used in the future.

6
Security
Used for applying security filters for user permissions.


This means that a filter set in a group different from FILTERGROUP 0 cannot be changed by a user that uses a filter dialog to set a filter. If, for example, a filter has been set on customer numbers 1000..2000 in group 4, the user can set a filter that delimits this selection further, but cannot widen it to include customer numbers outside the range 1000..2000.

It is possible to use one of the internally used groups from C/AL. If you do this, keep in mind that in this way, you will replace the filter that C/SIDE assumes is in this group. If, for example, you use FILTERGROUP 4 in a form, you will replace the filtering that is actually the result of applying the SubFormLink property. This could seriously alter the way forms and subforms interact.

Would anyone want to give it an explanation and the simple concrete examples?

Thank you in advance.
Regards,
Andwian

Answers

  • SPost29SPost29 Member Posts: 148
    I have used filtergroups in 2 ways:

    The key feature of filtergroups that I use is the fact that the filter is invisible and unremovable by the user.

    filtergroup(29)
    item.setrange("inventory posting group",'FINISHED');
    filtergroup(0)
    this sets a filter so the user can only see items that are finished goods

    the other way is when I want a filter to be set a certain way.
    I use an option choice and then that filter is only set by my code
    I may give the user 3 choices and set each one with my specifics.

    The filtergroup(0) puts any further filtering back in the standard filtering mode
    but keeps my filters set.
    to release my filters I have to enter filtergroup(29) again.

    Thats how I use them

    Steve
  • kinekine Member Posts: 12,562
    You can imagine filter groups as different layers on which you are setting the filters. Resulting filter is intersection between all layers (the filters are applied with AND between them). You can see and modify filters only in current filter group. E.g. TableRelation filter is set in one layer, user filter in different, form TableView filter in another one. User can see the intersection of all filters...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • AndwianAndwian Member Posts: 627
    Thanks Steve and Kamil,

    But would you give me more examples so that I could clearly understand them?

    Thank you in advance. :D
    Regards,
    Andwian
  • kinekine Member Posts: 12,562
    What is not clear on my description?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • krikikriki Member, Moderator Posts: 9,110
    Check here: http://www.mibuso.com/howtoinfo.asp?FileID=22. There is a section on filtergroups.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • AndwianAndwian Member Posts: 627
    kine wrote:
    What is not clear on my description?
    :oops: I am sorry, I need the example to make it clearer. But it's OK. Kriki has point to the right direction.
    kriki wrote:
    Check here: http://www.mibuso.com/howtoinfo.asp?FileID=22. There is a section on filtergroups.
    Thank you all :D
    I will check.
    Regards,
    Andwian
Sign In or Register to comment.