Dynamic filter for report w/out using request form

Sapphire123Sapphire123 Member Posts: 112
Hi All:

I'm trying to set a dynamic filter for a report based on the record number (Customer No.) - I"ve put the following code in the ' Customer - PreDataItem" trigger'

Setfilter("No.", Rec."No.");

However, it doesn't compile because of the undeclared 'Rec' variable. How do I set a dynamic filter for report without using the Request Form?

Thanks in advance..

Answers

  • idiotidiot Member Posts: 651
    Actually the usage should be Rec.SETFILTER(Rec."No.", whateverFilter)...
    Think you got the parameters mixed up
    NAV - Norton Anti Virus

    ERP Consultant (not just Navision) & Navision challenger
  • kinekine Member Posts: 12,562
    you can use
    Setfilter("No.", "No.");
    
    but do not forget that the Dataitem record is not inicialized in PreDataItem if you didn't use C/AL to init it (Find, Get etc.)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Sapphire123Sapphire123 Member Posts: 112
    Kamil,

    That's exactly what i'm trying to do..
    however, how do I intialize a record on predataitem trigger?..
    when I try the following code, it only picks up the first record and not the customer record (form) i'm on when I try to run the report.

    *** Customer - OnPreDataItem() ****

    Customer.GET("No.");
    SETFILTER("No.", "No.");

    ********************************
    The above doesn't work because it still doesn't intialized the record. I've tried putting this in the *** Customer - OnAfterGetRecord *** trigger also, but it keeps getting me the first record in the table. How do I initalize so that I filter on the current customer number? :roll:

    Thanks in advance.. !
  • Sapphire123Sapphire123 Member Posts: 112
    ok, i'm not sure if this is the right way to solve this problem... but, its working for now :)

    I used a single instance codeunit to share the selected record number - and to used this to set the filter for the report.
Sign In or Register to comment.