copyfilter not working

anand_sri12anand_sri12 Member Posts: 71
I am Trying to use copyfilter but not working here is the code
IncentiveLine.SETFILTER(IncentiveLine."Filter No.",'=%1',Slab);
IncentiveLine.COPYFILTER(IncentiveLine."Product Group
Name",Item_Rec."Product Group")
MESSAGE('%1',Item_Rec.COUNT);

In item table the product group is same as filtered for Incentiveline

It gives total no. of item i. e. 6893 which is not right it should tell 16
according to filter can anybody tell what is wrong.
With thanks

Anand Kumar
Navision Technical Consultant

Comments

  • anand_sri12anand_sri12 Member Posts: 71
    By analyzing I got it that we must set filter on that field which we want to copy to other
    i.e.
    IncentiveLine.COPYFILTER(IncentiveLine."Product Group Name",Item_Rec."Product Group")

    before copying we have to set filter on the same filed which we want to copy from
    but it is not serving well for me I cant set filter on the same field
    any body hv some idea how to cater this?
    With thanks

    Anand Kumar
    Navision Technical Consultant
  • MalajloMalajlo Member Posts: 294
    Example
    This C/AL code shows how to use the COPYFILTER function:
    Customer.SETFILTER("No.", '<1000'); 
    Customer.COPYFILTER("No.", Vendor."No."); 
    .
    .
    Count := Vendor.COUNT;
    
    The system copies and applies the filter set for Customer."No." to Vendor."No.". This affects the result of the Record.COUNT function, which counts how many vendors have a number less than 1000.
  • anand_sri12anand_sri12 Member Posts: 71
    Malajlo wrote:
    Example
    This C/AL code shows how to use the COPYFILTER function:
    Customer.SETFILTER("No.", '<1000'); 
    Customer.COPYFILTER("No.", Vendor."No."); 
    .
    .
    Count := Vendor.COUNT;
    
    The system copies and applies the filter set for Customer."No." to Vendor."No.". This affects the result of the Record.COUNT function, which counts how many vendors have a number less than 1000.

    I know this but probably you didnt got the problem
    With thanks

    Anand Kumar
    Navision Technical Consultant
  • KonradKonrad Member Posts: 30
    before copying we have to set filter on the same filed which we want to copy from
    but it is not serving well for me I cant set filter on the same field

    How about flowfield?
  • anand_sri12anand_sri12 Member Posts: 71
    Konrad wrote:
    before copying we have to set filter on the same filed which we want to copy from
    but it is not serving well for me I cant set filter on the same field

    How about flowfield?

    Dear

    I need it just for comparison purpose
    and infact i am using it in report so that i can hide unwanted data
    through currreport.showoutput(false).................................


    Let me b more refined
    Here I want to print those sales invoice lines record whose item falls in
    that particular Product group.
    With thanks

    Anand Kumar
    Navision Technical Consultant
  • EugeneEugene Member Posts: 309
    Item_Rec.SETRANGE("Product Group Code",Slab);
    MESSAGE('%1',Item_Rec.COUNT);
    Item_Rec.COPYFILTER("Product Group Code",IncentiveLine."Product Group Code");
    ProcessSelectedIncentiveLines;
    

    have in mind however that in principle Invoice lines may have several lines for the same item with different values of the "Product Group Code"

    if you want to filter by Item_Rec."Product Group Code" and not by IncentiveLine."Product Group Code" then you will have to iterate through records:
    Item_Rec.SETRANGE("Product Group Code",Slab);
    IF Item_Rec.FINDFIRST THEN 
    REPEAT
      IncentiveLine.SETRANGE(Type, IncentiveLine.Type::Item);
      IncentiveLine.SETRANGE("No.", Item_Rec."No.");
      ProcessSelectedIncentiveLines;
    UNTIL Item_Rec.NEXT=0
    
  • anand_sri12anand_sri12 Member Posts: 71
    Eugene wrote:
    Item_Rec.SETRANGE("Product Group Code",Slab);
    MESSAGE('%1',Item_Rec.COUNT);
    Item_Rec.COPYFILTER("Product Group Code",IncentiveLine."Product Group Code");
    ProcessSelectedIncentiveLines;
    

    have in mind however that in principle Invoice lines may have several lines for the same item with different values of the "Product Group Code"

    if you want to filter by Item_Rec."Product Group Code" and not by IncentiveLine."Product Group Code" then you will have to iterate through records:
    Item_Rec.SETRANGE("Product Group Code",Slab);
    IF Item_Rec.FINDFIRST THEN 
    REPEAT
      IncentiveLine.SETRANGE(Type, IncentiveLine.Type::Item);
      IncentiveLine.SETRANGE("No.", Item_Rec."No.");
      ProcessSelectedIncentiveLines;
    UNTIL Item_Rec.NEXT=0
    


    Dear
    My problem is
    I have a table whose (Lines) fields are
    Slab
    product group name
    63
    AA
    63
    AB
    63
    AC
    63
    AD
    63
    AE

    Now in a report the user selects the Slab 63 now we must show him only that records of sales invoice line in which the item product group code is that which falls in slab 63
    becase I only have slab information from header I cant setfilter on product group name instead i can only setfilter on slab
    i.e.

    IncentiveLine.SETFILTER(IncentiveLine.Slab,'%1',Slab);
    IncentiveLine.COPYFILTER(IncentiveLine."Product Group
    Name",Item_Rec."Product Group");
    Since I am not setting filter on product group name the copyfilter is not working
    With thanks

    Anand Kumar
    Navision Technical Consultant
  • anand_sri12anand_sri12 Member Posts: 71
    Dear All

    I want to copyfilter from a record to another without setting filter
    on that particular field which i am copying


    Customer.SETFILTER("No.", '<1000');
    Customer.COPYFILTER("No.", Vendor."No.");
    .
    .
    Count := Vendor.COUNT;

    i.e.
    Idont want to setfilter before copyfilter.
    It means I want to do this

    Customer.COPYFILTER("No.", Vendor."No.");
    .
    .
    Count := Vendor.COUNT;

    Anybody have some idea?
    With thanks

    Anand Kumar
    Navision Technical Consultant
Sign In or Register to comment.