Applying a FILTER to second Data Item on Report

erugalathaerugalatha Member Posts: 120
Hi,

I have a report that shows Items and Item Variants First data item is Item table and the second indented is Item Variant table. The Item Variant data item is not visible when I run the report as I have set a DataItemTableView set.

The filters on the Item data item include the Item Variant so how do I (in code) apply that filter to the second data item?

Thanks for your help.

Comments

  • ara3nara3n Member Posts: 9,258
    on triger onprereport put the following code

    Item.COPYFILTER("item Variant","Item Variant".COde):
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • gulamdastagirgulamdastagir Member Posts: 411
    you might as well set the dataitemlink property of the item variant dataitem as "Code=FIELD(Variant Filter)"
    Regards,

    GD
  • DnealDneal Member Posts: 103
    Hi,

    I am using Copyfilter. I have set a report to pull from dataitems:
    Sales Header
      Sales Line
    Sales Invoice Header
      Sales Invoice Line
    

    In the Sales Invoice line I have this code:
    "Sales Line".COPYFILTER(Type,"Sales Invoice Line".Type);
    "Sales Line".COPYFILTER("No.","Sales Invoice Line"."No.");
    "Sales Line".COPYFILTER(Quantity,"Sales Invoice Line".Quantity);
    "Sales Line".COPYFILTER("Line Amount","Sales Invoice Line"."Line Amount");
    

    Everything works great until the filters are choosen from the Sales Line and there are no existing records in the Sales Line. Then the filters are not carried to the Sales Invoice Line. They do not get picked up in the Sales Invoice Line until a record is found in the Sales Lines with those filters. So the first part of the report is wrong and then it suddenly looks perfect.

    Does anyone have a suggestion to how I can fix this?

    Dneal
  • markborgesmarkborges Member Posts: 170
    Maybe you should try a different nesting of the Dataitems:
    Sales Header
      Sales Invoice Header
      Sales Line
        Sales Invoice Line
    

    :-k
    Marcelo Borges
    D365 Business Central Solutions Architect
    BC AL/NAV C/AL Developer
    BC Repositories.com
  • DnealDneal Member Posts: 103
    Hmm, I'm not sure how that changes things. Could you please explain?

    I was hoping I wouldn't have to redo the dataitem or sections of he report.
  • markborgesmarkborges Member Posts: 170
    Dneal

    In order to suggest you an easy way to change these dataitems, I'd like to know what is the purpose of this report so that we can think of an ideal organization of the DItems.

    :wink:
    Marcelo Borges
    D365 Business Central Solutions Architect
    BC AL/NAV C/AL Developer
    BC Repositories.com
  • DnealDneal Member Posts: 103
    Hi Marcelo,
    Maybe you should try a different nesting of the Dataitems:

    Code:

    Sales Header
    Sales Invoice Header
    Sales Line
    Sales Invoice Line


    What I meant by how does this change things, was I don't understand how changing the dataitems will change the copyfilter function in an empty record. I just wanted an explanation on how changing the dataitems will affect the copyfilters function.

    Sorry for the confusion.

    Dneal
  • DnealDneal Member Posts: 103
    Is there a way to force/trick the dataitem into thinking it found a record when it didn't? I know this is out there, but I'm at a loss.
  • markborgesmarkborges Member Posts: 170
    My idea of change the dataitems order, is that you would have only sales invoice line if you found sales line.

    But after writing the post, I was wondering what you were really trying to do with these two tables.

    I'm not so sure if my advice will work for you, depending on what you want to do.

    :-k
    Marcelo Borges
    D365 Business Central Solutions Architect
    BC AL/NAV C/AL Developer
    BC Repositories.com
  • DnealDneal Member Posts: 103
    Hi again,

    The report is for a customer who would like to see item statistics based on a customer. They would like to see the orders(sales header and sales line) and also historical data(sales invoice header and sales invoice line). Since the filters they are using exist in both sets of dataitems I am using a copyfilter in the sales invoice header and sales invoice line. The customer does not want to have 4 tabs in the request form and have to repeat the filters. This is why it is being done this way. I have the following data items:
    Customer
      Sales Header
        Sales Line
      Sales Invoice Header
        Sales Invoice Line
    


    Unfortunatley, changing the order of the dataitems wouldn't give me the data I require.

    I'm still trying to find a way to make it copy the filters even if it doesn't find a record. It seems rather silly that this is how a Navision function works. ](*,)
  • MbadMbad Member Posts: 344
    You can always check if the filkters are blank and not apply them. Im pretty sure that will make you see the problem, cause i think your doing this wrong. Oh and btw Navision's own filters are not in filtergroup 0 on reports!
    It seems rather silly that this is how a Navision function works.

    Not sure what you mean.
  • DnealDneal Member Posts: 103
    Oh and btw Navision's own filters are not in filtergroup 0 on reports!

    What are you talking about?
  • DnealDneal Member Posts: 103
    Found what I needed! For anyone who runs into a similiar issue here is a link:

    http://www.mibuso.com/forum/viewtopic.php?p=70019#70019

    Thanks for all the input.
    Dneal
Sign In or Register to comment.