I’ve got a report that uses the Customer table, and the Value Entries. The user is “usually” filtering on Posting Date from the Value Entries using the report tab for the table. For example - let’s say they enter 04/01/03…04/30/03 (they COULD put in just one day or nothing at all too!). I’d like to retrieve the last date used in the filter (ex. 04/30/03)and use it as part of my Customer Date Filter - so I can show Customer.“Sales ($)” and Customer.“Profit ($)” as YTD values (so since year = 03, I’d make my date filter 01/01/03…04/30/03). In order to do this, I need to somehow be able to retrieve the filter from the Value Entry Table. I know I can use HASFILTER to determine if one exists, and GETFILTERS and put it in a text field, but then I’d have to pull out just the “Posting Date” field filter. I’m not even sure I’m headed in the right direction[B)]! Any ideas anyone?
Hi Faithie, take a look at the GETRANGEMIN and GETRANGEMAX functions. Eg.
Customer.SETFILTER("Date Filter",010102d,123102d); LastDate := Customer.GETRANGEMAX("Date Filter") // 12-31-02 Year := Format(LastDate,0,'<Year>'; // 02 Year4 := Format(LastDate,0,'<Year4><Month,2><Day,2>'); // 2002-12-31 Hope this can get you on track!
Soren, when I used the GETRANGExxx functions a few days ago, I noticed that an error is thrown when there is no range limit, e.g. when the filter is 01.01.02… etc. Is there any way to prevent this error and instead continue with some null value? Or did I do something wrong?
Hi Heinz Perhaps you may check the Filter string:
If (STRPOS(GetFilter(YourDateFilter),'..')>1) AND _ (STRLEN(GetFilter(YourDateFilter)) > (STRPOS(GetFilter (YourDateFilter),'..')+1)) then ; As always: without testing it [:D]. bye André
Andre, I have been using this method of searching for the ‘…’ in the filter string for quite a while. I have always considered it a bit “the Russian way” [:D] and, on one occasion, wanted to use a more elegant, portable and readable approach [:p] For example, what happens when the user enters a more complicated expression, e.g. consisting of several ranges combined with an or operator? Then any method relying on the ‘…’ occurring at a specific position in the string will most likely fail.
Hi Heinz Actually you are right [:)]. But if the user set another filter than a single value or a from-to range it seems GETRANGEMAX or GETRANGEMIN will not work.
From the Navision help GETRANGEMAX … The field you want to find the maximum value for. The current filter on Field must be a single range filter, otherwise a run-time error occurs. … Example With a filter which is not a single range: Customer.SETFILTER(“No.”,‘200|300’); Val := Customer.GETRANGEMAX(“No.”); This causes a run-time error to occur.
So you can add another string search (to the russian way [;)]):
If (STRPOS(GetFilter (YourDateFilter),'|') <> 0) Then Error('GETRANGEMAX/GETRANGEMIN will not work with this filter!\'+ 'Please try it again! Best regards Your admin');
Well, it depends upon what “single-range” means… obviously, “100…” is not considered “single-range”, because with this filter, GETRANGEMAX threw an error. Anyways, I will strongly consider putting this nice little message (“Best regards your admin”) into all my error messages [:D]
Originally posted by xorph
Well, it depends upon what “single-range” means… obviously, “100…” is not considered “single-range”, because with this filter, GETRANGEMAX threw an error.
But you can avoid it by using the right part of my first posting [8D]. My goal was it to catch both ("…100")/(“100…”) with my AND construction. Perhaps it would be better to use If (check left) - Else If (check right).
Anyways, I will strongly consider putting this nice little message (“Best regards your admin”) into all my error messages [:D]
Your users will love it [}:)]! bye André