Options

Application Management MAKEDATEFILTER

bhalpinbhalpin Member Posts: 309
As usual, something I thought would be simple has turned into a dog-fight.

I need to put a control on a report request form to collect a date filter. Looking at a stock example I went to form 490, Acc. Schedule Overview. There, the date filter is a textbox with the source expression "Acc. Schedule Line"."Date Filter". I copied that control to my request form, and added a global record for the "Acc. Schedule Line" table.

When I ran the report and entered '1.1.09..12.31.09' intothe control I got the error that that string was not a valid date. :-k

So, I traced through the triggers and found myself in codeunit 1 MAKEDATEFILTER. Without studying every line, it looked to me like this code would take a (var) string and cnvert it to a valid date filter - and return an integer value to denote success or failure. \:D/ Just what I needed!

So I changed the textbox to a text(250) var, and in it's OnValidate() trigger I put in a call to that function to validate/format the string entered, and display the integer result and the resulting string. The code looks like this:
MESSAGE('Result='+FORMAT(gcuApplicationManagement.MakeDateFilter(gtxtDateFilter))
+'\'+gtxtDateFilter
);

Well,, the result was sure disappointing. No matter what text I enter (good date filters, bad ones, complete gibberish, etc.) the integer result is always zero, and the string is unchanged.
So, either that function is 'broken', or I've misinterpreted what it is supposed to do.

Can anyone point out what I've missed?

Thanks in advance

Answers

  • Options
    bhalpinbhalpin Member Posts: 309
    Ok, in report 10028, Account Schedule, the OnValidate trigger for the date filter has this code:
    Acc. Schedule Name - OnValidate()
    IF ApplicationManagement.MakeDateFilter(DateFilter) = 0 THEN ;
    "Acc. Schedule Line".SETFILTER("Date Filter",DateFilter);
    DateFilter := "Acc. Schedule Line".GETFILTER("Date Filter");
    
    When I stole that and put it in my report (using a temprecord for "Acc. Schedule Line"), I now have the validation/formatting I am ooking for.

    I hope this helps the next person ...
  • Options
    awarnawarn Member Posts: 261
    Thanks, this did help the next guy (me) :)

    I had a textbox on a form where I wanted the user to enter a filter, and using your suggestion wrote the following function that is exactly what I need.


    SetUserFilters()
    IF AppMgt.MakeDateFilter(DateFilter) = 0 THEN;

    IF DateFilter = '' THEN
    SETRANGE("Posting Date")
    ELSE
    SETFILTER("Posting Date",DateFilter);
    DateFilter := GETFILTER("Posting Date");

    CurrForm.UPDATE(FALSE);
  • Options
    elmarfvelmarfv Member Posts: 53
    Thank you very much. This helped me out too.
    =D>
    Good work.

    Elmar.

    This should be posted in the How To Section here.
    Elmar F. Vidisson
    Certified Navision Attain Developer
  • Options
    bhalpinbhalpin Member Posts: 309
    I can't believe this! I'm adding a date filter to a request page and looking at MakeDateFilter and doing some tests. Can't figure it out. So I Google "NAV MakeDateFilter" and this is the 1st hit. And holy crap! It's a thread I started 10 years ago! If only we could remember everything. But there's Mibuso thanfully!
Sign In or Register to comment.