Copyfilters from Dataitem to record Variable

sunnyksunnyk Member Posts: 280
hi All,
i have one small doubt in copyfilters. I have 2 dataitems namely Vendor and Purch. Rcpt Line(Indented under Vendor). I made one Variable PurchRcptLine and i want to use that in vendor OnAfterGetRecord(). But i want that it should take all the filters which user give at the request form on Purch. Rcpt Line tab. So i used, PurchRcptLine.copyfilters(Purch. Rcpt Line).

IS that ok? for me i think its not working that why i put this query here?

Comments

  • garakgarak Member Posts: 3,263
    Good morning,

    try this:
    Report - OnPreReport()
    PurchRcptLine.copyfilters(Purch. Rcpt Line);
    
    Item - OnPreDataItem()
    error('The filters are = %1',PurchRcptLine.getfilters);
    

    Regards
    Do you make it right, it works too!
  • sunnyksunnyk Member Posts: 280
    HI Garak,
    I tried to copyfilters on On PreDataitem(first Dataitem) or OnAfterGetrecord(first Dataitem) but thr its not working.
    Lets say i have Vendor as my first dataitem and Purch Lines as indented Dataitem. i made one variable PurchLine. at the onPreDataItem of vendor if i write PurchLine.copyfilters(Purch Line) than i am getting nothing.
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    That's because your indented DataItem isn't really initialized at this point. Maybe you could move your to OnPreDataItem of your indented DataItem, but your filters set by DataItemLink won't be copied anyway.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • BeliasBelias Member Posts: 2,998
    other people's suggestions are correct, but i 2 more things to add (just for info):

    1. If you set a filter by code on a dataitem before the onpredataitem trigger of that dataitem, the filters will be lost (as einstein said, the variable is re-initialized at "onpredataitem time")
    2. You can probably copy the filters of the dataitemlink property by using filtergroup(4), but i've never tried it...i wonder if it works, it should :whistle:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    Belias wrote:
    2. You can probably copy the filters of the dataitemlink property by using filtergroup(4), but i've never tried it...i wonder if it works, it should :whistle:
    Yes, that's possible. But how to copy both (the ones set by user and the ones set by DataItemLink) filters? If you use COPYFILTERS a second time all previous set filters will be lost, right?
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • BeliasBelias Member Posts: 2,998
    For occasional readers: i'm just guessing, don't take this statement as it is true
    i don't have time to try, but probably code like this should work, as filtergroups should isolate the filters: :-k
    a.copyfilters(b);
    filtergroup(4);
    a.copyfilters(b);
    
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • vijay_gvijay_g Member Posts: 884
    edited 2010-04-21
    Belias wrote:
    1. If you set a filter by code on a dataitem before the onpredataitem trigger of that dataitem, the filters will be lost (as einstein said, the variable is re-initialized at "onpredataitem time")
    :whistle:
    it's woking fine.
    Belias wrote:
    2. You can probably copy the filters of the dataitemlink property by using filtergroup(4), but i've never tried it...i wonder if it works, it should :whistle:

    when i am using filtergroup(4) it does remove all filters like if i say just.
    onprereport trigger
    a.copyfilters(b);
    i got filters
    filtergroup(4);
    a.copyfilters(b); after this nothing..
  • vijay_gvijay_g Member Posts: 884
    Belias wrote:
    2. You can probably copy the filters of the dataitemlink property by using filtergroup(4), but i've never tried it...i wonder if it works, it should :whistle:
    Yes, that's possible. But how to copy both (the ones set by user and the ones set by DataItemLink) filters? If you use COPYFILTERS a second time all previous set filters will be lost, right?

    yes it's working when i checked it on onpredataitem trigger of under indented dataitem.
    but it's giving only dataitemlink filters even i have assign other filters at run time(before preivew).
    i think it does work only for dataitemlink filters..
  • BeliasBelias Member Posts: 2,998
    dataitem link filters are known before runtime: maybe you can try to use GETFILTER (singular) only on the fields you want :-k
    Sorry guys for just posting my thoughts without checking them...i'm as curious as busy up to now :mrgreen:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    I tested it, it works. Calling COPYFILTERS a second time doesn't remove the previous set filters, but it looks like because COPYFILTERS does also copy the filtergroup.

    This code should be placed in the OnPreDataItem of "Purch. Rcpt. Line".
    // this will copy all filters set by the user
    PurchRcptLine.COPYFILTERS("Purch. Rcpt. Line");
    // this will set the filtergroup to the level of DataItemLink
    FILTERGROUP(4);
    // this will copy all filters set by DataItemLink and also set the filtergroup of PurchRcptLine to 4
    PurchRcptLine.COPYFILTERS("Purch. Rcpt. Line");
    // might be necessary if you want to display all filters set by the user
    PurchRcptLine.FILTERGROUP(0);
    
    "Money is likewise the greatest chance and the greatest scourge of mankind."
Sign In or Register to comment.