How to set ReqFilterFields with default filter

sbillysbilly Member Posts: 231
When I run a report based on customer table, I want that its ReqFilterFields be filled with a default filter that I preset in advance.
For example :
Field Filter
Location Code Location1
Any Idea?

Comments

  • mohana_cse06mohana_cse06 Member Posts: 5,503
    If we run Sales Invoice report from Posted Invoices then No. will be automatically flown to reports reqfilterfields..
    have look how it is working
  • sbillysbilly Member Posts: 231
    I know how it's working.
    But in my case I must run the report from the object designer.
  • sbillysbilly Member Posts: 231
    You have to use Options tab..
    I didn't understand ??
  • Mike_HWGMike_HWG Member Posts: 104
    I know this is an old topic, but I'd like to respond for two reasons:

    1. This thread happens to be in the top Google search for this topic
    2. This topic has not been sufficiently answered in any of the top search hits.

    See my response in this thread
    Michael Hollinger
    Systems Analyst
    NAV 2009 R2 (6.00.34463)
  • cvmngacvmnga Member Posts: 1
    Here is another solution:

    Part 1 – Add the fields that will default on the Request Page.

    1. Open the Development Environment.
    2. Change the license to the Developer’s License.
    3. Open the Report in Object Designer.
    4. Go to a new row at the bottom of the Report Designer.
    5. Click on the properties button or (Shift+F4).
    6. Make sure the “UseRequestPage” Property is set to Yes.
    7. Close the Property Page.
    8. Select the Row where the Table Name is displayed.
    9. Click on the properties button or (Shift+F4).
    10. Enter the table name.
    11. Click on the ellipse for the “ReqFilterFields” Property.
    12. Add the fields to be filtered and click on the OK button.
    13. Close the Properties window.
    14. Close the report designer.
    15. Say OK to compile the report.

    Part 2 – Add the code to the page

    1. In the Object Designer, select the Page where the report will be printed from and click on the Design button.
    2. Click on View in the menu.
    3. Select Page Actions.
    4. Select the line where the report is shown.
    5. Click on C/AL Code or (F9).
    6. Click in the trigger.
    7. Click on View in the menu.
    8. Select C/AL Locals.
    9. Enter a name for the Variable, select Record as the Data Type, and enter the Table Name for the Subtype. This is the table used in the report.
    10. Close the C/AL Locals window.
    11. In the trigger enter the variable name you created, a period, the function name “SETRANGE”, and in parentheses enter the field name, a comma and the field name again. Make sure the field names are in quotes. Example: ItemLedgerEntry.SETRANGE("Item No.","Item No.");
    12. Repeat the previous step for every field that will be defaulted.
    13. Change Rec in the REPORT.RUN command to the variable name you created.
    14. Close the C/AL Editor.
    15. Close the Action Designer window.
    16. Close the Page Designer.
    17. Click “Yes”.
    18. Open the page where the report appears on the ribbon and select the row to include in the report.
    19. The report filters default to the row values.

    Sorry - I had really nice screen shots. I wish I could add them.
  • Mark_SmartMark_Smart Member Posts: 16
    There is a trick for doing this that I worked out many years ago.

    -Create a report, say, "Item Filter Test" with an Item dataitem.
    -Create a global variable Item2 as record, table 27.
    -Create a global boolean variable RunFromSelf.
    -Create a non local function SetRunFromSelf, with the only code:
    RunFromSelf := TRUE;
    -Close and save the report.
    -Reopen in designer and add a global Report variable pointing to the same report called ThisReport
    -Put something in the request options form/page, even if it's a hidden lable. This forces the request options tab form/page to be displayed, and it's page triggers to run.
    -In the Request Options Form or Page, OnOpenPage/OnOpenForm trigger, add the following code:

    IF NOT RunFromSelf THEN BEGIN
    Item2.SETRANGE("No.",'1234');
    ThisReport.SetRunFromSelf;
    ThisReport.SETTABLEVIEW(Item2);
    ThisReport.RUNMODAL;
    ERROR('');
    END;

    Basically you have a report which can be run from object designer, from a menusuite, or through simple code using Report.RUN(<some repot id in a table>), which assigns it's own default filter which can be changed by the user. The report runs itself, then pops out with a blank error (the dirty part).

    With more tinkering you can retain saved user filters. I'm fairly sure that in much older versions of Navision you could directly change the filters via filtergroups in the OnOpenForm trigger without having to resort to ERROR('').
Sign In or Register to comment.