Must compile form to clear flowfilter

dutzdutz Member Posts: 10
I have a table as the source of a form. I am setting the range of a date flowfilter for this table. The dates are for the previous month from the system date. It works fine. After the form is run, it is closed. When the system date turns to the next month, i.e. April 1st, and the form is run on April 1st, the data returned is from the previous month as if it were run on March 31st (02/01/09..02/28/09). I output the filter string set on the flowfilter before I set it and it is blank. Afte I set it I output it again and my filter is there (03/01/09..03/31/09 when run on April 1st) yet the data is still from the month before. Here is the odd part. If I compile the form, it works correctly again. I can change my system date to re-create the problem, but it is only "cleared" by compiling the form, NOT compiling the table.

Comments

  • kinekine Member Posts: 12,562
    If you set some filters on the form, the form is "remembering" the filters if set to Save the TableView. You can "disable" this, or you can add some code to set the filter through code to correct values in OnOpenForm. Or you can learn users how to set the filter on beginning of the month. But I do not see any "bug" or something in your description...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • dutzdutz Member Posts: 10
    Let me explain clearer.

    In the table I have a flowfield with this formula ("Sales Last Month Date Filter" is a flowfilter)

    Sum("Detailed Cust. Ledg. Entry"."Amount (LCY)" WHERE (Posting Date=FIELD(Sales Last Month Date Filter),Document Type=FILTER(Invoice|Credit Memo)))

    In OnInit I set "Sales Last Month Date Filter" (the get functions return the first and last day of the previous month from the system date) :

    SETRANGE("Sales Last Month Date Filter", GetLastMonthDate_fu(0),GetLastMonthDate_fu(1));

    If I run the form today I get the data from 03/01/09..03/31/09. This is what I want.

    If I don't compile the form until May 1st, when I run it I will get the same data from 03/01/09..03/31/09. After running it and seeing data from March, I compile the form and run it again (still May 1st). It works again giving me data from 04/01/09..04/30/09.

    At that point I can then change my system date to anything and I will still get data from 04/01/09..04/30/09. If I compile the form, I can change my system date to anything, and it will give me the previous months data correctly.
  • kinekine Member Posts: 12,562
    It is because you are setting it in OnInit. The prcess is this:

    1) C/Side is creating the form
    2) OnInit
    3) C/Side will read saved values from .zup file
    4) OnOpen


    As you can see, the saved values will overwrite your settings each time after first run. You need to set the filter in OnOpen, not in OnInit... :whistle:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • dutzdutz Member Posts: 10
    So then compiling the form changes the zup file?

    If the zup file is user specific then why does my compiling allow another user on another workstation to get this result. In other words, he runs it and gets the issue. I compile it from another workstation logged in as myself (and with a different license). He then sees the corrected behavior.

    BTW, thanks for your help.
  • kinekine Member Posts: 12,562
    Settings in zup for some object are not used, if the object was changed between saving the values and restoring them. It means if someone set some filter on some object and you recompile it, these settings will not be used when the user start he object. This is how the system works.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • dutzdutz Member Posts: 10
    Thank you. Your input is greatly appreciated.
Sign In or Register to comment.