I have a report with a Data Item on system table Date.
I have fill out the ReqFilterFields property to ask for "Period Start" filtering.
If you filter for '01/01/08..TODAY' the report works.
But if you filter for '01/01/08..' the report have to pass through all records from Date table and this is not good.
So, I have created a function which detect that you didn't gave the TO value and create a TO value using the TODAY function.
The problem is that I am trying to filter the Date table manually and I can't.
Here is the code:
{
Variables
DateFilter is a TEXT.
DateFilter2 is a DATE.
Date is the Date system table.
}
DateFilter := Date.GETFILTER("Period Start");
IF COPYSTR(DateFilter, STRLEN(DateFilter), STRLEN(DateFilter)) = '.' THEN BEGIN
EVALUATE(DateFilter2, COPYSTR(DateFilter, 1, STRLEN(DateFilter)-2));
Date.SETRANGE("Period Start", DateFilter2, TODAY);
END;
The report just ignore the SETRANGE and continue to run with the previous filter '01/01/08..'
Why?
Comments
We will need to see more of your code and triggers to see what is wrong. If you debug your program what values does the filter have?
I tried to reset it, nothing.
I tried to use a different variable for the Date table and then COPYFILTERS from it, nothing.
If I enter it correct from the begging it works.
](*,)
You need to get the field filters in the OnPreReport trigger (keep them in variables) and then apply your actual filters in the OnPreDataitem trigger... I think that filters applied in the onprereport trigger are reset to user's choice after that trigger. So where is your code :?:
And I use the GetFilters exactly after the SETRANGE to see if the filter is ok, and it is.....????????
I put my code OnPreDataItem trigger and it works now.
Also GETRANGEMAX gives me an error because the user write '010108..' and he never fill the MAX range.
That's why I did it with COPYSTR.
Problem Solved.