Get filter information from request form

Sapphire123Sapphire123 Member Posts: 112
Hi All,

what function do i use to extract the filter value from a request form of a report?

thanks.

Answers

  • SavatageSavatage Member Posts: 7,142
    are you talking about GETFILTERS?
  • kinekine Member Posts: 12,562
    Hi All,

    what function do i use to extract the filter value from a request form of a report?

    thanks.
    It depends on WHEN you want them. You cannot read them before the report is printed/previewed. All filters can be read in PreReport trigger, and after that you can read fitlers in PreDataItem and other DataItem triggers, but just for the actual DataItem or any Parent DataItem. You cannot read filters for nested dataitems...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • XypherXypher Member Posts: 297
    If you are adjusting the filters for your report on the RequestOptionsForm I go about it this way...

    Set global variable(s) to the DataItem(s) your RequestOptionsForm will apply to.

    Every control on the form calls a function I make (something like "UpdateFilters" or what have you) and it appears like this:
    UpdateFilters()
      globalRecordvar.RESET;
      globalRecordvar := DataItemRecord; 
    
      //Apply all filters according to what is enabled/has value
    
      //...this I have on every RequestOptionsForm and I find it to be rather informative as well as "nifty"...
      IF globalRecordvar.ISEMPTY THEN
        gRecordCount := 0
      ELSE
        gRecordCount := globalRecordvar.COUNT;
    

    (I have a textbox which shows the value of gRecordCount letting the e/u know how many records there are with the current filter(s) applied.)

    To apply the filters...
    DataItemRecord - OnPreDataItem()
      COPYFILTERS(globalRecordvar); //Copy filters from record variable used in RequestOptionsForm
    
  • Sapphire123Sapphire123 Member Posts: 112
    can someone pls post an example?
    i'm trying to get filters in predataitem of a report.
    how do i use 'getfilters' function?

    thanks in advance for your help..
  • kinekine Member Posts: 12,562
    Just read the online help for the GETFILTERS, there is example... ;-)
    GETFILTERS (Record)
    Use this function to return a string which contains a list of the filters within the current filter group for all fields in a record. In addition, this function also returns the state of MARKEDONLY.

    String := Record.GETFILTERS
    String

    Data type: text constant or code

    This string contains a list of the filters for all fields in Record.

    Record

    Data type: record

    The record from which you want a list of filters.

    Comments
    See also GETFILTER, SETFILTER, and SETRANGE.

    Example
    This example shows how to use the GETFILTERS function.

    "Cust. Ledger Entry".SETRANGE(Amount, -100, 100);
    "Cust. Ledger Entry".SETRANGE(Date, 010196D, 123196D);
    Str := "Cust. Ledger Entry".GETFILTERS;
    MESSAGE(Text000 + '%1', Str);

    Create the following text constant in the C/AL Globals window:

    Text Constant
    ENU Value

    Text000
    'The filters are:\'


    The system displays this message:

    The filters are:
    Amount: -100..100, Date: 010196..123196
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • SavatageSavatage Member Posts: 7,142
    you can look at reports like Aged A/R 10040

    go to the last dataitem - on the blank line under the last dataitem put your cursor & hit F9

    You'll see
    **Get Your Filters
    OnPreReport()
    FilterString := COPYSTR(Customer.GETFILTERS,1,MAXSTRLEN(FilterString));
    
    **Show Your Filters
    Now when you view the sections you'll see a textbox with properties of:
    Customer.TABLECAPTION + ': ' + FilterString
    
Sign In or Register to comment.