Hi, all! Here is the situation: we have a long list of reports and some of our users are confused in finding the reports they regularly use. My first thought was to tell the users to filter their Report List, so their own filter would be kept in the zup file. That’s why I changed the SaveTableView property to “Yes” (Report List form) and SourceTablePlacement property to “Saved”. Unfortunately, this didn’t solve my problem, because in the OnOpen trigger of the form there is a code setting its own filters, which overwrites the filters from the zup file (if they are saved in the zup at all). Here is the code in the OnOpenForm trigger: LangID := CurrForm.LANGUAGE; FILTERGROUP := 2; IF GETFILTER(“Menu ID”) = ‘’ THEN SETRANGE(“Menu ID”,FIELDNO(“G/L Reports”)); FILTERGROUP := 0; IF NOT FIND(’-’) THEN BEGIN ReportList.COPY(Rec); FORM.RUNMODAL(FORM::“Reports - Modify”,ReportList); Refresh(Rec); IF NOT FIND(’-’) THEN CurrForm.CLOSE; END; CALCFIELDS(“Menu Name”); DataCaption := “Menu Name”; Is there any simple solution to make Navision keep this custom applied filters in the zup file and re-apply them when the form is opened again? P.S. I tryed to save the filter in my own txt file: OnOpenForm(): IF EXISTS(‘c:\repfilt.flt’) THEN BEGIN f.OPEN(‘c:\repfilt.flt’); f.READ(filt); n:=STRLEN(filt); filt:=COPYSTR(filt, 1, n-2); MESSAGE(’’+filt+’’); SETFILTER(“Report ID”,filt); END; OnCLoseForm(): filt:=GETFILTER(“Report ID”); f.CREATE(‘c:\repfilt.flt’); f.TEXTMODE:=TRUE; f.WRITE(filt); f.CLOSE; but in the OnCloseForm trigger the GETFILTER function returns an empty string, so I assume somewhere in the middle the filters are reset. Thanks in advance for the suggestions!
No idea about the code - but I can offer a slightly less sophisticated approach: Just use the modify option on the report list, delete the reports and then reconstruct the reports with the most commonly used at the top. You may also leave off completely any reports that you know you will never use. Also, create dummy report in the customers range with the name ‘-----’ or something similar. You can then use this report on all the report menu’s as a seperator at logical points in the report list. Unfortunately the menu’s will be the same for all user, but that isn’t usually a problem from ledger to ledger.
Hi, I’ve tried to get the Filter in field “report id” of the Item- Reportlist Form 282 in the OnCloseForm-Trigger in 3.60 with MESSAGE(Rec.GETFILTER(“Report ID”)) and it works. Is there any other individual programming in your form? Greetings, Frank
Hi, Frank! I tried this too. When you set the filter with Table Filter (ctrl-F7), it works. When you set it with Field Filter (F7), the GETFILTER returns an empty string. And more: if the filter is set by the SETFILTER function in OnOpenForm and the user doesn’t change manualy the filter in the form, in the OnCloseForm the GETFILTER function returns empty string again. I don’t have a clue why that behaviour occurs ?!?
Hi Kamen, I’ve tried the same as you, Filtering with F7 and Filtering with SETRANGE in the on OpenFormTrigger, and it works. Where did you place your code in the OnOpenForm-Trigger? Beofre or after the original code? Can you show the complete code of both Triggers? Greetings, Frank
This is all my code in the form Report List: OnOpenForm() LangID := CurrForm.LANGUAGE; FILTERGROUP := 2; IF GETFILTER(“Menu ID”) = ‘’ THEN SETRANGE(“Menu ID”,FIELDNO(“G/L Reports”)); FILTERGROUP := 0; IF NOT FIND(’-’) THEN BEGIN ReportList.COPY(Rec); FORM.RUNMODAL(FORM::“Reports - Modify”,ReportList); Refresh(Rec); IF NOT FIND(’-’) THEN CurrForm.CLOSE; END; CALCFIELDS(“Menu Name”); DataCaption := “Menu Name”; //IF EXISTS(‘c:\repfilt.flt’) THEN //BEGIN // f.OPEN(‘c:\repfilt.flt’); // f.READ(filt); // n:=STRLEN(filt); // filt:=COPYSTR(filt, 1, n-2); // MESSAGE(’’+filt+’’); //SETFILTER(“Report ID”,filt); //END; OnCloseForm() //filt:=GETFILTER(“Report ID”); //MESSAGE(filt); //f.CREATE(‘c:\repfilt.flt’); //f.TEXTMODE:=TRUE; //f.WRITE(filt); //f.CLOSE; OnAfterGetRecord() IF CurrForm.LANGUAGE <> LangID THEN BEGIN Refresh(Rec); LangID := CurrForm.LANGUAGE; END;
Hi Kamen, I’ve tested your code and modify it a little bit: In OnOpenForm-Trigger added: IF EXISTS(‘c:\repfilt.flt’) THEN BEGIN f.OPEN(‘c:\repfilt.flt’); f.READ(filt); n:=STRLEN(filt); filt:=COPYSTR(filt, 1, n-2); MESSAGE(’’+filt+’’); SETFILTER(“Report ID”,filt); f.CLOSE; END; OnCloseTrigger: filt:=GETFILTER(“Report ID”); IF NOT f.CREATE(‘c:\repfilt.flt’) THEN f.OPEN(‘c:\repfilt.flt’); f.TEXTMODE:=TRUE; f.WRITE(filt); f.CLOSE; But there were only Problems with the file, not with GETFILTER. The above code works fine, with setting the Filters by F7 and Strg+F7. Greetings, Frank
Thanks, Frank! Now it works fine. I suppose that I will have to compicate the code a litle to reflect the different modules (GL, Inventory, etc.) that call Report List Form with different filters. Obviously this functionality couldn’t be handled by the Navision and the zup file, but with a litle bit of coding this problem should be bridged over. Thanks once more time for the help and for your time!
Hi Kamen, Just an idea: Perhaps you should store the filters for each module and each user in a new table and not in a Textfile?!? Greetings, Frank
Yes, I thought about that too, but the task isn’t so complex that requireing a table and I’m trying to minimize the use of licences for new tables also. Other thing from the background of the task is that it is a request from just a few users. If more users request such functionality, we may think of creating a new table with information about report filters and (just an idea) statistics of report usage [:)]