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
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 ...
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);
=D>
Good work.
Elmar.
This should be posted in the How To Section here.
Certified Navision Attain Developer