How get the filter from a dataitem

DarkHorseDarkHorse Member Posts: 389
Dear folks, I'd like to know how do this. I've a report with 4 dataitems, in groups of two, I mean that they are in the same report but works different and doesn't are linked between them, I execute one or the other clicking the option on the request form and, in sections, I show it or hide.
But now I want that when I filter by "Order Date" on first Dataitem, the third dataitem gets also the filter that I put (this dataitem also has the "Order Date" field). How can I do that?.
Thanks.

Comments

  • matttraxmatttrax Member Posts: 2,309
    Lookup the GETFILTER method. It works on a record and you supply it a field as a parameter. It will return the filter string on that field.
  • DarkHorseDarkHorse Member Posts: 389
    Thanks, but where put the code, Onaftergetrecord (I think)? I had try putting
    Var1:= "Purch. Rcpt. Header".GETFILTER("Order Date"); but it doesn't work. Can you put me an example if you're so kind?
    Thanks in advance.
  • DRBDRB Member Posts: 105
    Hi,
    To get the filter on first table:
    On PreReport Trigger:
    Rec1.GETFILTER("Order Date");

    For applying this filter to 2nd table:

    On PreReport Trigger:
    Rec2.CopyFilter("Order Date",Rec1."Order Date");

    Hope this helps
    -Dhan Raj Bansal
    Linkedin Profile: http://in.linkedin.com/in/dhanrajbansal
  • kinekine Member Posts: 12,562
    For applying this filter to 2nd table:

    On PreReport Trigger:
    Rec2.CopyFilter("Order Date",Rec1."Order Date");

    To apply the filter you need to apply it in OnPreDataItem not in OnPreReport, else it would be reset in OnPreDataItem... if I remmember correctly
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • DRBDRB Member Posts: 105
    Yes Kine, you are right...my mistake
    -Dhan Raj Bansal
    Linkedin Profile: http://in.linkedin.com/in/dhanrajbansal
  • DarkHorseDarkHorse Member Posts: 389
    Thanks for reply. Rec1 and Rec2 are variables or tables? if are varibles what kind?.
    Thanks for help.
  • kinekine Member Posts: 12,562
    They are variables representing the Data Items in your report...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • DarkHorseDarkHorse Member Posts: 389
    Thanks; I thinks there's a little problem. If I put onPredataitem from the first table
    Rec1.GETFILTER("Order Date"); it says to me "Have to use the return value of this work" and stops after GETFILTER. Do you know what can be the problem, please?.
    Thanks.
  • SavatageSavatage Member Posts: 7,142
    Create a Variable Type Text - FilterString (250)

    FilterString := Rec1.GETFILTER("Order Date");

    Add a textbox to you report with SourceExp = Filterstring

    If I remember correctly :-k

    **Edit I guess I should have read the first post slower**
    On PreReport Trigger:
    Rec2.CopyFilter("Order Date",Rec1."Order Date");
  • DarkHorseDarkHorse Member Posts: 389
    Thanks for reply, now I can save the report but doesn't works, the second group of Dataitems don't filter buy the date. It's true that I don't put the code that you say:
    Add a textbox to you report with SourceExp = Filterstring
    Sorry, but I don't understand it, where and how I have to put it?.
    Thanks for help.
  • SavatageSavatage Member Posts: 7,142
    What I thought you were looking for was to show the filter being used on the report. But I glanced instead of read your first post. You want to copy a filter to a different dataitem.

    So filterstring gave you the return variable that the error message was looking for. If you added a textbox w/filterstring as it's sourceexp and put it in the header (for example) it would printout. that's all, that was about.

    can you explain what you are doing on the second dataitem that isn't working?

    Rec2.CopyFilter("Order Date",Rec1."Order Date"); did you try this?
    Rec2.CopyFilter("Order Date",evaluate(filterstring)); perhaps? not tested

    Each dataitem has it's own OnPreDataItem
  • DarkHorseDarkHorse Member Posts: 389
    Thanks; I thinks it's all correct, but I'll see deeper all what you're saying to me.
    Thanks for your help and time.
Sign In or Register to comment.